brendan at mozilla.org
Wed Apr 2 16:14:42 PDT 2008
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:
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
> IMO we're looking for simple and useful comprehensions for ES4. I
> think extensions like the ones you are suggesting, though clearly
> 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.
>> 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.
More information about the Es4-discuss