PEP 308: A PEP Writer's Experience - PRO

Erik Max Francis max at
Mon Feb 10 09:01:09 CET 2003

Andrew Henshaw wrote:

> Perhaps, I am looking at this backwards, however.  In this case (iff
> function), it's clear that the function definition needs to support
> lazy
> evaluation.  But, I can see where there would be cases where it didn't
> look
> like it was needed; but, the caller is annoyed that he can't use my
> function "lazily".

Well, there's no doubt that if you want an iff (still a bad choice of
names, since in mathematics that means "if and only if," not the meaning
intended here) that does short circuiting, it has to lazily evaluate
some of its argument; it has to be a special form.  I think one of the
strengths of Python is that it _doesn't_ have special forms; I know when
I see something written as the argument to a function, it's going to get
evaluated before that function gets called.  Some operators (and, or)
support lazy evaluation, but in my opinion introducing lazily evaluation
functions would open a huge can of worms.  Or at least, I can't see how
it wouldn't.

> Despite that, I don't believe that lambda would be a good explicit
> solution,
> either.

It's a good solution when you want a general form of lazy evaluation and
want it to be explicit, I think.  (It obviously doesn't work if you want
_implicit_ lazy evaluation.)  Why wouldn't it be?  Zero-argument lambdas
are in fact precisely how lazy evaluation is implement in some

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ No man quite believes in any other man.
\__/ H.L. Mencken
    Alcyone Systems /
 Alcyone Systems, San Jose, California.

More information about the Python-list mailing list