This removes the secret channel from the call function. Having it made it more complicated to write new function engines, and it's not clear why it was even needed in the first place. It seems that even the current generation of function engines work just fine without it. Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
27 lines
666 B
Plaintext
27 lines
666 B
Plaintext
-- main.mcl --
|
|
# this was originally: optimized-higher-order-function.txtar
|
|
import "fmt"
|
|
|
|
func apply($f, $x) {
|
|
$f($x)
|
|
}
|
|
$add1 = func($x) {
|
|
$x + 1
|
|
}
|
|
$z = apply($add1, 1)
|
|
|
|
test [fmt.printf("%d", $z),] {}
|
|
-- OUTPUT --
|
|
Edge: FuncValue -> call # fn
|
|
Edge: call -> callSubgraphOutput # dummy
|
|
Edge: callSubgraphOutput -> printf: func(format str, a int) str # a
|
|
Edge: const: str("%d") -> printf: func(format str, a int) str # format
|
|
Edge: printf: func(format str, a int) str -> composite: []str # 0
|
|
Vertex: FuncValue
|
|
Vertex: call
|
|
Vertex: callSubgraphOutput
|
|
Vertex: composite: []str
|
|
Vertex: const: int(1)
|
|
Vertex: const: str("%d")
|
|
Vertex: printf: func(format str, a int) str
|