block lambda revival
Waldemar Horwat
waldemar at google.com
Mon May 23 13:44:46 PDT 2011
This seems too brittle to me. The examples conveniently include only lambda parameters in their function calls. Suppose you have:
a = f{|| 42}
and want to add a second lambda parameter:
a = f{|| 42}{|x| x*x}
So far so good, ignoring the little bug that || is a different token than two |'s (we've yet to have a coherent discussion about what really can go into these parameter lists).
Now you want to add a third integer parameter:
a = f{|| 42}{|x| x*x}(7)
Well, that won't work, as it curries rather than supplying the third parameter. Instead you'd need to do:
a = f({|| 42},{|x| x*x},7)
Oh, and don't forget to now insert the comma between the }{. You'll get something entirely different (a lambda called with a lambda parameter, which it then ignores) if you omit it.
The other problem is the necessity of the [no line terminator here] imposed by semicolon insertion. It's very tempting to write
a = f
{|x| x*x}
which will at best be a syntax error or at worst be two separate statements (depending on whether we allow a lambda to start a statement).
Waldemar
More information about the es-discuss
mailing list