lhansen at adobe.com
Wed Apr 2 18:01:08 PDT 2008
> -----Original Message-----
> From: Brendan Eich [mailto:brendan at mozilla.org]
> Sent: 2. april 2008 17:15
> To: Lars Hansen
> Cc: Jason Orendorff; Jeff Dyer; es4-discuss
> Subject: Re: grammar update
> On Apr 2, 2008, at 1:03 PM, Lars Hansen wrote:
> > Looks like those restrictions (condition only at the end,
> only 'for',
> > 'for each', and 'if' clauses) originate in Brendan's original
> > (too-sketchy) proposal, see the "Comprehensions" section of
> this page:
> > http://wiki.ecmascript.org/doku.php?
> > id=proposals:iterators_and_generator
> > s
> This is my fault -- I went by the examples in
> and did not include the full grammar from
> cited therein -- apologies to all and thanks to Jason for
> pointing this out.
> > IMO we're looking for simple and useful comprehensions for ES4. I
> > think extensions like the ones you are suggesting, though clearly
> > useful, should be prototyped elsewhere before going into
> the language
> > spec, or at a minimum, be presented in a better developed proposal.
> 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.
> Jason wrote:
> >> Separately, I would appreciate let clauses in ArrayComprehensions:
> >> [[trial, phi]
> >> for each (trial in trials)
> >> let (phi = hugeExpensiveCalculation(trial))
> >> if (phi < 1000)]
> >> Haskell has this feature. I occasionally reach for it in
> Python and
> >> it isn't there.
> Lars, you didn't cite this use-case for let statements, aka
> let blocks :-P. Firefox 2 and 3 (JS1.7 and 1.8) have support
> for let blocks, but again not embedded in comprehensions. As
> Jason notes, Python didn't follow Haskell here (if that was
> the order of evolution). I don't propose we do this for ES4,
> since let blocks are "out" according to all who've opined on
> the spreadsheet.
The syntax Jason uses is not for let blocks, but for let
expressions. 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.
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.
(The page the generator proposal is on is already far too large;
I suggest that you break generators out as a separate proposal.)
More information about the Es4-discuss