Expression closures - use-cases for shortcut lambda syntax (blocks)

Lars T Hansen lth at acm.org
Fri Mar 16 05:26:26 PDT 2007


On 3/16/07, Igor Bukanov <igor at mir2.org> wrote:
> On 16/03/07, Brendan Eich <brendan at mozilla.org> wrote:
> > Yes, you are right -- ES3 allows Unicode identifiers, so this would
> > not be a backward compatible change. It seems excessive anyway, if \
> > (x)x is acceptable for (lambda (x) x).
>
> And if farther
>   \(args) expression
> would stand for
>   function(args) { return expression; }
>
> then JS would be close to beating ML and friends in shortness of
> defining lambdas.

Shortness isn't a reasonable metric by itself.  (Beating ML and
Haskell even less so.)  The language has to balance compactness and
clarity.  And though ES has aspects of a functional language (and ES4
will be even more so than ES3), it is more fundamentally imperative.
No doubt many uses will be found for the expression function syntax,
but going to this level of terseness does not seem to be justified.
As Tucker said, programs are read much more often than they're
written.  "function" provides all readers with a reasonable idea about
what follows.  "\" is overly terse, and makes sense only if you think
"lambda" would make sense in the same context (I don't, particularly
-- it's bad UI, to use Brendan's terminology).

--lars



More information about the Es4-discuss mailing list