grammar update

Brendan Eich brendan at mozilla.org
Wed Apr 2 18:13:34 PDT 2008


On Apr 2, 2008, at 6:01 PM, Lars Hansen wrote:

>> This is all thin syntactic sugar, so I don't agree it rocks
>> the boat too much to follow the full prototype in Python.
>> I'll update the proposal, since it claims to follow the PEP,
>> but fails since the PEP cites the RM.
>
> The PEP is scarcely relevant; what we need are comprehensive
> proposals for ES4.

Touché (again; last time, I won't grovel :-/). My point is that the  
proposal is intended to avoid novelty in comparison to Python,  
especially novelty due to my poor mistake. Not all of ES4 is yet  
fully or even well-specified (e.g., packages -- this was clear from  
the last TC39 meeting). But where use-cases are strong, we are  
persevering, not rejecting over surface-syntax transcription errors,  
or even deeper issues.

> The syntax Jason uses is not for let blocks, but for let
> expressions.

Syntax is secondary to context in making the point that let forms  
containing statements are useful. I'm not quibbling, or trying to  
revive let statements; I am simply citing a use case for the record.

>  Not that I see how it matters, since surely the
> 'for each' and 'if' forms in array comprehensions are not
> meant to be taken to be the same as their statement counterparts
> in all ways.

They de-sugar internally to statements. The implementation in JS1.7  
transforms the AST in the obvious way before handing it off to the  
code generator. The only new AST node is the one representing the  
consumer of the displayed expression (the expression on the left of  
'for'), which is a built-in form of Array push, as noted in the  
proposal.

These are not anything but statements as far as the programmer can  
tell, but of course the syntax is restricted. I'm happy to fix the  
unintended over-restriction.

> Please do update the spec for comprehensions; I will not make
> it my job to figure out what you meant by studying Python.  The
> spec that's there is too informal as well, consisting only of
> illustrative examples.  It needs (probably) a grammar and
> semantics at a minimum.

Ok.

> (The page the generator proposal is on is already far too large;
> I suggest that you break generators out as a separate proposal.)

Will do.

/be




More information about the Es4-discuss mailing list