Allen's lambda syntax proposal
David-Sarah Hopwood
david.hopwood at industrial-designers.co.uk
Thu Dec 4 12:52:51 PST 2008
David-Sarah Hopwood wrote:
> Jon Zeppieri wrote:
[...]
>> 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
>> }
>> }
>
> Strictly speaking, the syntax is not ambiguous; it just is not parsed
> how you might expect. The semicolons would be inserted in this example
> as follows:
>
> ^(x) {
> x = (x * x)^(a, b, c, d, e, f, g);
> { x; }
> };
>
> Arguably, the problem here is that semicolon insertion is and always
> was a bad idea.
>
>> 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}
>> }
>
> Same result as above.
Sorry, not the same result. This would be formally a syntax error,
although note that some implementations do perform semicolon insertion
even at non-line-boundaries.
--
David-Sarah Hopwood
More information about the Es-discuss
mailing list