You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fun returnSum(a: number, b: number): number {
return a + b;
}
// Closures
fun identity(a: (number, number) => number): (number, number) => number {
return a;
}
print identity(returnSum)(1, 2); // prints "3";
currently results in an error Cannot call a non-function
(Actually, the comment 'Closures' is in my view a misnomer, it is 'just' passing a function reference (or value or pointer (?) ) as an argument. The feature of closures is not used here, that the current scope of variables is preserved for the later execution of the function.)
Expected behaviour would be that function identity is called with reference to function as argument, which is returned,
and then apply (1, 2) on that function returnSum and execute it.
Passing functions as arguments and then calling them does not yet quite work in the langium-lox example language interpreter · Issue #4 · TypeFox/langium-lox
Activity