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

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.

--lars

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Jason Orendorff
> Sent: 2. april 2008 13:46
> To: Jeff Dyer
> Cc: es4-discuss
> Subject: Re: grammar update
> 
> On Sun, Mar 30, 2008 at 7:29 PM, Jeff Dyer <[EMAIL PROTECTED]> wrote:
> >  I've updated the ES4 grammar files linked from
> >   http://wiki.ecmascript.org/doku.php?id=proposals:normative_grammar
> 
> Thanks for doing this.  I noticed that the grammar doesn't allow this:
> 
>   [addr
>     for each (user in users)
>       if (user.isAdministrator)
>         for each (addr in user.addresses)]
> 
> Is this intentional?  Both Python and Haskell allow the 
> analogous listcomp.  (Oddly enough, if you anti-optimize 
> this, moving the IfCondition to be after the last 
> ForInExpression, the proposed ES4 grammar accepts that.)
> 
> 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.
> 
> -j
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
> 
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to