ternary operator

Tim Peters tim_one at email.msn.com
Fri Feb 7 00:13:29 EST 2003


[James J. Besemer]
> ...
> Seems to me:
>
> (a) an initial identifier may constitute the beginning of an
> expression or a statement but the parser can handle it.  Why is it an
> issue for 'if'?

It would be the first such case in Python.

> (b) if this is an actual problem for existing Python parsers (I
> don't know if it is or not),

You have the source code.  The grammar is in file Grammar/Grammar, and the
makefile knows how to drive Python's parser generator.

> such designs are certainly not beyond the capabilities of
> other (say) 1980s era parser technology.

For that matter, they weren't beyond Fortran's parsing technology in the
50's either.

> (c) parsing is further simplified if different tokens are used for
> expressions vs. statements, ala C, in contrast with Algol60.
>
> Most importantly, adding conditional expressions to the language is NOT
> a technical problem.  The principal issues are ideological.

I don't know what that means, but I agree there's no insurmountable
technical problem.  As I mentioned last week, Guido already implemented a
ternary operator for Python.  His patch is on SourceForge, and I gave a URL
for it last time.  He rejected his patch, though.  Look up the patch for
more.






More information about the Python-list mailing list