JasonSteving99/claro-lang

Add Lambda Expressions

Closed this issue · 1 comments

Let's add lambda expressions to the language mostly to provide some convenient way to make single-use procedures, but also to provide a convenient mechanism for implicit scope grabbing closures (or however you wanna describe that).

I'll work on the syntax later, but this lambda should have access to the variable defined before it:

var i = 99;
var foo: provider<int> = () -> i;
var bar: consumer<int> = (x) -> print(x + i);
var baz: function<int -> int> = (x) -> x + i;
print(foo()); 
bar();
print(baz(10));

This is done after a83a49c