Expression closures - use-cases for shortcut lambda syntax (blocks)
Andrew Dupont
andrew at andrewdupont.net
Fri Mar 16 15:36:00 PDT 2007
> So without an idiom from another language, I'm cool again. Sorry, but
> feel free to propose a better syntax. We are not out of room in the
> grammar yet!
>
How about a slightly-modified version of Ruby's block syntax?
(10).times( |number| {
console.log(number);
});
The pipe character delimits the arguments, with the only difference
being that the arguments occur outside of the braces. In Ruby this would be
10.times { |number| puts number }
Cheers,
Andrew
More information about the Es4-discuss
mailing list