PistonDevelopers / dyon

A rusty dynamically typed scripting language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Higher Order Calls

bvssvni opened this issue · comments

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.

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)

Closing, see #610 (comment)