For review: PEP 308 - If-then-else expression

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Sun Feb 9 00:15:46 EST 2003


"Paul Paterson" <hamonlypaulpaterson at houston.rr.com> writes:
> >    print cond(x >= 0, :sqrt(x), :"imaginary roots")
> >
> > I don't see immediately whether this makes any syntax ambiguities with
> > existing statements, since I can't think of anyplace where colon can
> > currently appear where an expression can also appear.
> 
> When I first saw this I thought it was horrible - you can hardly tell that
> the ":" is there.
> 
> About two hours later I thought, "wait a minute - you don't really need to
> see that the ":" is there... its mostly irrelevant except when you are
> particularly interested in the delayed evaluation". Lazy evaluation should
> be almost invisible because it is a semantic "pass".
> 
> I await the next two hours with interest to see if I completely change my
> mind again.

I think it's good to show the deferred evaluation in the caller
somehow.  The equivalent in C is the convention of writing
preprocessor sybmols in ALL CAPS.

There have been a few different macro schemes (hygienic and otherwise)
discussed here in clpy as well.  Maybe something like that can be
considered for Python 3000.

FWIW, I haven't "declared" but if I understand these ratings, I'm +1
on the concept of having some kind of conditional expressions in
Python and about -0.5 on PEP 308 (I don't like the condition in the
middle).  I haven't seen any other concrete proposals that I'm
much above neutral about, hence my "perfect crystal" post.




More information about the Python-list mailing list