Files
mgmt/lang/interpret_test/TestAstFunc1/changing-func.txtar
James Shubin 37bb67dffd lang: Improve graph shape with speculative execution
Most of the time, we don't need to have a dynamic call sub graph, since
the actual function call could be represented statically as it
originally was before lambda functions were implemented. Simplifying the
graph shape has important performance benefits in terms of both keep the
graph smaller (memory, etc) and in avoiding the need to run transactions
at runtime (speed) to reshape the graph.

Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
2025-04-27 22:14:51 -04:00

42 lines
691 B
Plaintext

-- main.mcl --
# this can return changing functions, and could be optimized, too
func funcgen($b) {
if $b {
func() {
"hello"
}
} else {
func() {
"world"
}
}
}
$fn1 = funcgen(true)
$fn2 = funcgen(false)
$out1 = $fn1()
$out2 = $fn2()
test "${out1}" {}
test "${out2}" {}
-- OUTPUT --
Edge: FuncValue -> if # a
Edge: FuncValue -> if # a
Edge: FuncValue -> if # b
Edge: FuncValue -> if # b
Edge: const: bool(false) -> if # c
Edge: const: bool(true) -> if # c
Edge: if -> call # fn
Edge: if -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: const: bool(false)
Vertex: const: bool(true)
Vertex: if
Vertex: if