Block lambda is cool, its syntax isn't

François REMY fremycompany_pub at yahoo.fr
Fri Jan 20 13:38:16 PST 2012


Just to add weight to my previous mail, you may find it interesting to 
notice that my proposed syntax match nearly exactly the proposed syntax of 
the new Mozilla-editored Rust programming language: 
http://doc.rust-lang.org/doc/tutorial.html#closure-compatibility

    call_twice({|| "I am a stack closure; });

    call_twice(fn@() { "I am a boxed closure"; });

It confirms my feeling about {|| ...}: it should only be allowed in a 
context where the function still exists; it's a way to return the control 
back to the calling function when you need to call a "callback-able" 
function for some reason. At every other place, you should use 'normal' 
closures (the language-agnostic equivalent of ECMAScript functions), for 
which we should have a simplified syntax (aka syntaxic sugar). I don't 
bother if it has to start by @, #, %, µ, § or anyting else, but I feel 
strongly about the fact we need it.

Now, I think everyone got my point, I leave the final discussion to group 
members. But, at least, my message was sent. ;-)

Best regards,
François 



More information about the es-discuss mailing list