ternary operator

James J. Besemer jb at cascade-sys.com
Fri Feb 7 00:03:08 EST 2003


Tim Peters wrote:

> The distinction between expressions and statements, much stronger in Algol
> 60 than in Python (every Python expression is a Python statement; no Algol
> 60 expression is an Algol 60 statement; 

this may be true but I don't think it is relevant.

> a consequence is that if Python were
> to add conditional expressions of the if/then/else form, seeing an initial
> "if" would not be enough to distinguish the expression form from the
> statement form, and that has consequences; [...]

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'?

(b) if this is an actual problem for existing Python parsers (I don't know if 
it is or not), such designs are certainly not beyond the capabilities of 
other (say) 1980s era parser technology.

(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.

Regards

--jb

-- 
James J. Besemer		503-280-0838 voice
2727 NE Skidmore St.		503-280-0375 fax
Portland, Oregon 97211-6557	mailto:jb at cascade-sys.com
				http://cascade-sys.com	







More information about the Python-list mailing list