Allen's lambda syntax proposal

Jon Zeppieri jaz at bu.edu
Wed Dec 3 18:45:24 PST 2008


On Wed, Dec 3, 2008 at 9:36 PM, Eric Suen <eric.suen.tech at gmail.com> wrote:
>
>
> No,
>
> ^(x) is not a legal expression, so you don't have to make
> block in same line, no semicolon insertion will happens here.

You're looking at the wrong part of the example.  Sorry -- the
"wrapper" lambda is superfluous, and I should have left it out for
clarity.

Using the GNU bracing style:

x = x * x
^(a,b,c,d,e,f,g)
{
  x
}

The above parses as an xor expression followed by a block, like so:

x = x * x ^ (a,b,c,d,e,f,g)
{
  x
}
... which is odd, to be sure, but perfectly legal.


The second example:

x = x * x
^(a,b,c,d,e,f,g) {x}

is not ambiguous, but it's unsuitable for top-down parsing.  (I tried
to underscore the point by using a long list of formals.)  The parser
has to get to the opening brace before it can determine that it isn't
dealing with an xor expression.

-Jon



>
> see this post:
>
> https://mail.mozilla.org/pipermail/es-discuss/2008-December/008296.html
>
> ----- Original Message -----
> From: "Jon Zeppieri" <jaz-jxCPH4jmHUs at public.gmane.org>
> Newsgroups: gmane.comp.lang.javascript.ecmascript4.general
> To: "P T Withington" <ptw-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org>
> Cc: "es-discuss" <es-discuss-4eJtQOnFJqFAfugRpC6u6w at public.gmane.org>
> Sent: Thursday, December 04, 2008 3:09 AM
> Subject: Re: Allen's lambda syntax proposal
>
>
>> 2008/12/3 P T Withington <ptw-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org>:
>>>
>>> - prefix ^ might be confused with the infix operator of the same name
>>
>> With semicolon insertion, isn't this a bigger problem?
>>
>> The opening brace will need to be on the same line as the formals,
>> otherwise the syntax is ambiguous:
>>
>> ^(x) {
>>  x = x * x
>>  ^(a,b,c,d,e,f,g)
>>  {
>>    x
>>  }
>> }
>>
>> And, if it is on the same line, it's still bad for a top-down parser:
>>
>> ^(x) {
>>  x = x * x
>>  ^(a,b,c,d,e,f,g) {x}
>> }
>>
>> Will semicolon insertion be illegal inside a lambda body?
>>
>> -Jon
>
>
>
>


More information about the Es-discuss mailing list