Higher Order Calls
bvssvni opened this issue · comments
Sven Nilsen commented
Split from #610
Higher Order Calls
Higher Order Calls are supported by external functions that return some value:
a := \(x: f64) = x + 1
b := exp(a)
This is the same as:
a := \(x: f64) = x + 1
b := \(x: f64) = {
a := grab a
exp(\a(x))
}
The above is inlined to this:
a := \(x: f64) = x + 1
b := \(x: f64) = exp(x + 1)
When calling a loaded function, closures are accepted as normal parameters:
fn main() {
a := \(x: f64) = x + 1
println(foo(a)) // prints `\(x: f64) = exp(x + 1)
}
foo(x: f64) = exp(x)
The type checker "believes" that closures returning f64
are acceptable as f64
arguments.
Sven Nilsen commented
I wonder whether we could use \
with no parameters to tell Dyon to do a higher order call:
a := \(x: f64) = x + 1
b := exp(\a)
Sven Nilsen commented
Closing, see #610 (comment)