ternary operator

Mike Meyer mwm at mired.org
Thu Feb 6 20:19:40 EST 2003


Alex Martelli <aleax at aleax.it> writes:

> I believe you misremember.  Pascal, as designed (as a language for
> newbies) by N. Wirth, had no conditional expressions (and no logical
> operators that ensured short-circuiting, either).  Pascal was a very
> deliberate reversion to simplicity from the complications of Algol-68
> (I _think_ Algol 60 didn't have "short-circuiting conditional expressions"
> either, and it did make a distinction between statements and expressions,
> like Pascal and unlike Algol 68 -- but it's been far too long since I
> actually used Algol for me to feel certain about it), so that is hardly
> surprising.

You're right about Algol. No short circuiting conditionals. I don't
remember if the "block expression" was an Algol-W ism or from Algol
60.

Hey, that's what we need to make the people who want an assignment
operator happy! Block expressions.

Proposed syntax:

block:
        <statements>
        expression

and the value of the block is the value of the last expression in the
block. So you can write:

if block:
    value = calculations()
    value == 3:
        calcuation_with_value(value)

and so on.

And yes, I really did write Algol that did things like

while begin statements; exrepssion end do begin statements end

I-hope-no-one-takes-this-seriously-ly,        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.




More information about the Python-list mailing list