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
As in this resource and popular other languages. Anonymous functions are great. However, we should probably decide on an identifier for them which is not function, so as to not treat every function as a lambda, but also because JavaScript has shown us that typing out function everywhere is annoying. Additional enhancement would be to allow anonymous function bodies to have no curly braces around them, so we can write very nice short function bodies.
I propose using a simple backslash as the lambda introducer; to whit:
// Using a traditional block;
schedule(1000, 0, \(%name) {
echo("Hello" SPC %name);
}, "Peter");
Additionally, we should support calling functions from variables:
Working branch. Decided to go with plain old function(). Currently the function name is returned, but not defined until the end of the current script parsing. This means that anon functions can't be used in top-level expressions where they are called immediately - for example, typing in the console call(function(%a) { echo(%a); }, horses);. Fixed in 170a4ea.
As in this resource and popular other languages. Anonymous functions are great. However, we should probably decide on an identifier for them which is not
function
, so as to not treat every function as a lambda, but also because JavaScript has shown us that typing outfunction
everywhere is annoying. Additional enhancement would be to allow anonymous function bodies to have no curly braces around them, so we can write very nice short function bodies.I propose using a simple backslash as the lambda introducer; to whit:
Additionally, we should support calling functions from variables:
The text was updated successfully, but these errors were encountered: