From: | Andy Walker <news@cuboid.co.uk> |
Newsgroups: | comp.compilers |
Date: | Sat, 05 Mar 2011 14:36:28 +0000 |
Organization: | Compilers Central |
References: | 11-03-006 11-03-009 |
Keywords: | syntax, history |
Posted-Date: | 05 Mar 2011 10:39:29 EST |
On 04/03/11 20:50, glen herrmannsfeldt wrote:
> ALGOL, I believe ALGOL 60 (I don't know the versions very well)
> has the "conditional arithmetic expression" as:
> A := IF I<0 THEN R ELSE 3;
> That is the example from Baumann, et. al, "Introduction
> to ALGOL" from 1964, I believe describing ALGOL 60.
> I don't know when it originated in ALGOL.
That is indeed in Algol 60; there is no trace of any such
animal in "Algol 58" [IAL]. Note that because there is no closing
bracket, you often need extra parentheses in a more complicated
situation.
By Algol 68, the construction has gone the whole hog, and
you can use "if ... fi" on the LHS of an assignment:
if x < y then x else y fi := 1;
or to select functions [but, sadly, not operators]:
z := if x < y then sin else cos fi (pi/5);
etc., etc. Note that "( ... | ... | ... )" can always be used in
place of "if ... then ... else ... fi" and is usually the more
appealing syntax when the "..." are simple; in general, the "..."
can be replaced by an arbitrarily complicated serial clause, even
within arithmetic expressions.
--
Andy Walker,
Nottingham.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.