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

http://www.python.org/dev/peps/pep-0202/

and did not include the full grammar from

http://www.python.org/doc/current/ref/lists.html#l2h-238

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.

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.

/be

_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to