Block lambda is cool, its syntax isn't

Jon Zeppieri zeppieri at gmail.com
Thu Jan 12 15:41:36 PST 2012


On Thu, Jan 12, 2012 at 5:52 PM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
>
> On Jan 12, 2012, at 2:23 PM, François REMY wrote:
>
> Am I wrong if I say there not a bigger issue with block lambda than with the
> current object notation on the matter?
>
>
> I think you're correct.  An ExpressionStatment can not begin with a {
> so,without changing that rule,  there should be no potential for ambiguity
> between Block and BlockLambda.  The only issue is distinguishing
> ObjectLiteral and BlockLambda  and from that perspective a {(  is as good as
> a {| as neither is ambiguous with existing ObjectLiteral syntax,

An additional consideration: for a block lambda's completion value to
be another block lambda, the {( syntax would require parenthesis,
while the {| syntax would not:

let succ =
  {(x)
    {(s)
      {(z)
        s(x(s)(z))
      }}};

With the grammar François is suggesting, this would be a syntax error
(I think), since the body of a block lambda is a StatementList_opt.
The {| syntax, on the other hand, can accommodate block lambdas as
expression statements, though, given another token of lookahead
(again, I think).


More information about the es-discuss mailing list