Files
mgmt/lang/interpret_test/TestAstFunc1/simple-lambda2.txtar
2023-06-01 16:56:44 -04:00

30 lines
940 B
Plaintext

-- main.mcl --
import "fmt"
# this should be a function as a value, iow a lambda
$answer = func() {
"the answer is 42"
}
$out1 = $answer()
$out2 = $answer()
test $out1 + $out2 {}
-- OUTPUT --
Edge: call:answer() -> var(out1) # var:out1
Edge: call:answer() -> var(out2) # var:out2
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: str("+") -> call:_operator(str("+"), var(out1), var(out2)) # op
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
Edge: var(out1) -> call:_operator(str("+"), var(out1), var(out2)) # a
Edge: var(out2) -> call:_operator(str("+"), var(out1), var(out2)) # b
Vertex: call:_operator(str("+"), var(out1), var(out2))
Vertex: call:answer()
Vertex: call:answer()
Vertex: func() { str("the answer is 42") }
Vertex: str("+")
Vertex: str("the answer is 42")
Vertex: var(out1)
Vertex: var(out2)