[Python-Dev] conditional expressions?
Daniel Mahler
mahler@cyc.com
Mon, 15 Oct 2001 22:40:47 -0500
Has an if(cond,exp1,exp2) syntax been considered?
It would have the advantage that existing
syntax sensitive editors would handle without change.
I think conditional exprs badly needed,
but the if/then/else syntax seems too verbose for use inside
expressions.
regards
Daniel Mahler
Tim Peters writes:
> [Paul Svensson]
> > ...
> > I know there's been a long time request for this feature,
> > supposedly from people coming to Python from C,
> > but what's the real reason for adding it now,
> > without even a PEP ?
>
> The reason for *considering* it right now is a rapidly closing window of
> opportunity -- 2.2b1 goes out later this week. A fellow on c.l.py has been
> plugging away at a PEP, Eric Raymond submitted a working patch for C's ?: in
> January of 2000, Jim Fulton loved the idea then (but not particularly the ?:
> spelling), David Ascher reported that lack of a conditional was a FAQ in his
> classes then, etc etc. Most replies hated the ?: syntax, and Guido
> eventually remembered (although I think he forgot it this time around) that
> Algol-60 used the obvious if/then/else. His reply on Mon, 31 Jan 2000
> 09:36:52 -0500:
>
> The solution can be the same as what Algol used: 'if' outside
> parentheses is a statement, and inside parentheses is an expression.
> It's a bit of a grammar rearrangement, but totally unambiguous.
>
> However, the added keyword means it won't be in 1.6. The lively
> discussion means that Eric's patch will have a hard time getting
> in too...
>
> The only difference between then and now is s/1.6/2.2/.
>
> > Does it really add enough to the language to justify the bloat ?
>
> I expect most people would say it does; by definition I'll adjust my beliefs
> to whatever Guido decides <wink>.
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev