ternary operator

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Thu Feb 6 20:21:59 EST 2003


Tim Peters <tim.one at comcast.net> writes:
> 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

Very cool!

> 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.  Algol 60 (from the revised
report) definitely supported short-circuiting conditional expressions.
>From section 3.3.3:

    In the more general arithmetic expression, which include if clauses,
    one out of several simple arithmetic expressions is selected on the
    basis of the actual values of the Boolean expression (cf. section
    3.4. Boolean expressions). This selection is made as follows: The
    Boolean expressions of the if clauses are evaluated one by one in the
    sequence from left to right until one having the value true is
    found. The value of the arithmetic expression is then the value of the
    first arithmetic expression following this Boolean (the largest
    arithmetic expression found in this position is understood). The
    construction:

    else <simple arithmetic expression>

    is equivalent to the construction:

    else if true then <simple arithmetic expression>


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




More information about the Python-list mailing list