grammar update

Lars Hansen lhansen at
Wed Apr 2 13:03:20 PDT 2008

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:

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.


> -----Original Message-----
> From: es4-discuss-bounces at 
> [mailto:es4-discuss-bounces at] 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 <jodyer at> wrote:
> >  I've updated the ES4 grammar files linked from
> >
> 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 at

More information about the Es4-discuss mailing list