ternary operator

François Pinard pinard at iro.umontreal.ca
Thu Feb 6 22:07:22 EST 2003


[Alex Martelli]

> Pascal, as designed (as a language for newbies) by N. Wirth, had no
> conditional expressions (and no logical operators that ensured
> short-circuiting, either).

If I remember well (that was a while ago), the Pascal language reference
left undecided a few things, like if logical operators were allowing
short-circuiting or not, the order of evaluation of actual arguments (and
irrelevantly, the behaviour of integer division with negative arguments),
meaning that programmers could not rely on the order of evaluation, or the
non-evaluation, when expression evaluations had side effects.

For what it's worth, in the original Pascal implementation, by Urs Amman
(not sure of spelling) under the direction of Niklaus Wirth, logical
operators were evaluated in full and never short-circuited, but once again,
programmers were not allowed to rely on this.

On the machine Pascal was first implemented (CDC 6000 series), jump
instructions were rather costly (time-wise), and so was integer division, so
great lengths were taken in the compiler generator and run-time library to
avoid needing them, as far as possible.

> Pascal was a very deliberate reversion to simplicity from the
> complications of Algol-68 [...]

I think I've heard, at the time, that Niklaus Wirth, who wrote Algol-W by
the time, was invited on the design committee for Algol-68, but slammed the
door relatively early.  You might remember that Algol 68 has been, and for
long, notoriously difficult to compile.

Niklaus Wirth mainly selected and merged a few good ideas into what became
Pascal.  E. Dijkstra for control structures, C.A.R. Hoare for data
structures, and I guess D. Gries for the compiler design and organisation,
or at least, the compiler seemed to follow Gries a bit slavishingly.

> (I _think_ Algol 60 [...]

Algol 60 design was such that it forced a rather slow run-time in many ways,
and much contributed to the wide spread opinion among computer specialists
that elegance and speed could not live together.  Pascal tried to repair
that opinion, and the compiler implementation was very fond on generating
code that runs fast, nearly to the point of exaggeration.  This has been
corrected in later versions of the original compiler, especially when the
compiler maintenance was later moved from E.T.H. Zurich into U.S. (through
the doings of Andy Mickle at U. Minnesota?  I am not sure), where some speed
was traded in favour of maintainability and better integration with the
operating system.  Yet, for a while, Niklaus Wirth has been reluctant to
these changes, despite they had no real effect on the language reference.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list