ternary operator

Tim Peters tim.one at comcast.net
Fri Feb 7 02:46:39 CET 2003


>> The Algol 60 Revised Report is available online; e.g., a nice
>> rendering with a few helpful hyperlinks is at
>>
>>     http://www.masswerk.at/algol60/report.htm

[Paul Rubin]
> Very cool!

Yup.

>> Your memories are all on target.  Unlike as in Python, a bare
>> expression isn't allowed where a statement is required (Python
>> blurred the distinction for the benefit of interactive mode), so
>> there's no confusion between Algol 60's if/then/else conditional
>> statement and Algol 60's if/then/else arithmetic expression (an
>> "if" is the start of an Algol 60 statement if and only if "if" is
>> the first token of a statement following the statement's labels
>> (if any)).

> I'm not sure what you're getting at here.

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; 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; Algol 60 didn't have this
problem).

> Algol 60 (from the revised report) definitely supported short-circuiting
> conditional expressions.

I didn't mention short-circuiting, although Alex did.  I took his mention of
short-circuiting to mean that Algol 60's spelling of the boolean "and" and
"or" operators didn't short-circuit, which they didn't.  Of course the "if
e1 then e2 else e3" flavor of conditional expression evaluated exactly one
of {e2, e3}.  IOW, I did Alex the minor favor of assuming he wasn't an idiot
<wink>.

...

>> Better to go to the source:  the Algol 60 report is still a marvel of
>> succinct clarity.

> It's been said that Algol 60 is one of the few languages so well
> designed that it improved not only on its predecessors, but on most of
> its successors as well.

Worth repeating.






More information about the Python-list mailing list