-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lang: ast, parser: Allow calling anonymous functions
I forgot to plumb this in through the parser. Pretty easy to add, hopefully I didn't forget any weird corner scope cases here.
- Loading branch information
1 parent
1af334f
commit 1538bef
Showing
6 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- main.mcl -- | ||
$s = func() { | ||
"hello" | ||
}() # inline lambda call | ||
|
||
test [$s,] {} | ||
-- OUTPUT -- | ||
Vertex: test[hello] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- main.mcl -- | ||
$s = func($x) { | ||
"hello" + $x | ||
}("world") # inline lambda call | ||
|
||
test [$s,] {} | ||
-- OUTPUT -- | ||
Vertex: test[helloworld] |
10 changes: 10 additions & 0 deletions
10
lang/interpret_test/TestAstFunc2/call-inline-lambda3.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- main.mcl -- | ||
import "fmt" | ||
|
||
$s = fmt.printf("%v", func($x) { | ||
len($x) | ||
}("helloworld")) # inline lambda call | ||
|
||
test [$s,] {} | ||
-- OUTPUT -- | ||
Vertex: test[10] |
10 changes: 10 additions & 0 deletions
10
lang/interpret_test/TestAstFunc2/call-inline-lambda4.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- main.mcl -- | ||
import "fmt" | ||
|
||
$s = fmt.printf("%v", func($x) { | ||
len($x) | ||
}(func($x){ $x }("helloworld"))) # inline lambda call as an arg to another | ||
|
||
test [$s,] {} | ||
-- OUTPUT -- | ||
Vertex: test[10] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters