Files
mgmt/lang/interpret_test/TestAstFunc2/constant-sub-graph.txtar
Samuel Gélineau 16dfb7b5f5 lang: Add more test cases related to future graph optimization
We are planning to implement an optimization in which some function
calls are compiled to a single static graph rather than to a CallFunc
which dynamically creates a sub-graph at runtime. These test cases
exercise corner cases for which it would be theoretically possible to
use a static graph, but which we might not be able to optimize.
2024-01-20 15:01:56 -05:00

18 lines
442 B
Plaintext

-- main.mcl --
import "os"
$apply1 = func($f, $x) {
$f($x)
}
$apply2 = func($f, $x) {
$f($f($x))
}
$apply = if (os.system("echo 0; echo 1") == "0") {$apply1} else {$apply2}
$id = func($y) { $y }
# since $apply changes over time, this call needs a dynamic sub-graph. In
# theory, the $f calls above do not need a sub-graph, but does our optimization
# support this corner case yet?
test $apply($id, "foo") {}
-- OUTPUT --
Vertex: test[foo]