On Fri, 31 Dec 2004 00:19:29 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote:
>Jp Calderone wrote:
> > On Fri, 31 Dec 2004 00:00:31 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote:
> > 
> >>Paul Rubin wrote:
> >>
> >>>Nick Coghlan <[EMAIL PROTECTED]> writes:
> >>>
> >>>
> >>>>Anyway, I'm looking for feedback on a def-based syntax that came up in
> >>>>a recent c.l.p discussion:
> >>>
> >>>
> >>>Looks like just an even more contorted version of lambda.  It doesn't
> >>>fix lambda's main deficiency which is inability to have several
> >>>statements in the anonymous function.
> >>
> >>Do you consider generator expressions or list comprehensions deficient 
> >>because 
> >>they don't allow several statements in the body of the for loop?
> >>
> > 
> > 
> >     >>> (foo + bar
> >     ...     for foo in range(13) if foo % 3 == 2
> >     ...     for bar in range(16, 23) if 2 <= bar % 5 < 4)
> >     <generator object at 0xb7dec10c>
> >     >>> 
> > 
> >   Hmm.  Two for loops and two if clauses.  That's four altogether.  
> > Does that qualify as "several"? :) Sure, they're not statements 
> > according to the grammar, but that's entirely beside the point.
> > 
> >   Jp
> 
> And that's an expression, and hence perfectly legal as the body of an 
> anonymous 
> function.

  Quoting my response again:

> Jp Calderone wrote:
> > Sure, they're not statements according to the grammar, but 
> > that's entirely beside the point.

  I thought this was obvious to anyone, oh well.

  List and generator comprehensions have special syntax so that behavior 
normally acheivable only with statements can be used to control their 
execution.  Lambdas don't have any similar special syntax.

  I'm not saying "boo hoo lambdas are crippled fix them waah".  I'm saying 
"Lambdas and generator comprehensions are not comparable in this sense and 
arguments based on one should not be used to support positions about the 
other".

  Jp
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to