From: Peter Seibel
Subject: history of conditional expressions
Date: 
Message-ID: <m31xytp4if.fsf@javamonkey.com>
I've read that McCarthy invented the "conditional expression". As I
understand it, the key point that the conditional expression was an
*expression* meaning something that returned a value? As opposed to
the IF statement in the FORTRAN of the era, that was really a
conditional jump. Yet most languages outside the Lisp family have an
IF *statement* not an IF expression. (Well, there's always the ternary
operator in C-derived languages, but it's usually pretty limited, e.g.
Java's version.) But the modern IF statement in C, Perl, or Java is
not just a conditional jump either so seems more related to
Lisp/McCarthy's COND than to FORTRAN I's IF.

Paul Graham mentions in [1] that "McCarthy ... was on the Algol
committee, [and] got conditionals into Algol, whence they spread to
most other languages" and cites [2]. I haven't been able to track down
an online copy of McCarthy's article that turned into a letter to the
editor in a 1959 CACM.

Anyway, is it fair to say that the modern IF statement in
Algol-derived languages such as C, Perl, and Java, is in fact
descended from Lisp's COND.

(I understand that the possibility of cross-fertilization and
Lamarckian effects make language cladistics a fuzzy undertaking. I'm
just looking for opinions and historical data points.)

-Peter

[1] <http://www.paulgraham.com/diff.html>
[2] <http://www-formal.stanford.edu/jmc/history/lisp/node2.html>

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp

From: Kenny Tilton
Subject: Re: history of conditional expressions
Date: 
Message-ID: <3ECB06D8.3070200@nyc.rr.com>
Peter Seibel wrote:
> I've read that McCarthy invented the "conditional expression". 

Me, too. From:

http://www8.informatik.uni-erlangen.de/html/lisp/histlit1.html

"The example was a chess program which was restricted to the normal 
FORTRAN version. McCarthy became unhappy with the language elements for 
conditional actions. The "arithmetical IF", with its narrow restriction 
to comparison with 0 and the constraint to do conditional function IF 
with three arguments. It delivered the value of the second or third 
argument if the first resulted in the value 1 or 0, respectively. This 
enabled a clean function-oriented programming, but was neither very 
efficient nor as nice as it should have been. Because of the 
call-by-reference parameter passing mechanism of FORTRAN all arguments 
are evaluated, wheras only two are actually needed. This unused 
computation puzzled McCarthy and he explored the problem thoroughly. In 
the end, he developed the idea of conditional expressions..."

> Paul Graham mentions in [1] that "McCarthy ... was on the Algol
> committee, [and] got conditionals into Algol..."

Oh. the above history continues:

"It is known that conditional expressions were not all the proposals 
that McCarthy had made for the new programming language. Most of them 
were rejected already by the subcommittee or adjourned and put into a 
"second volume". In Z"urich, the conditional expressions and the 
conditional statement were also rejected. McCarthy was not a member of 
the ACM-delegation and therefore his recollection: "I made a lot of 
propaganda for the inclusion of conditional expressions in ALGOL ... and 
in 1958 I lost, namely the idea was too unfamiliar, and I didn't explain 
it well enough, so I did not succeed in getting this thing in ALGL in 
1959 ..."(22) does not explain what happened. "

> 
> Anyway, is it fair to say that the modern IF statement in
> Algol-derived languages such as C, Perl, and Java, is in fact
> descended from Lisp's COND.

Could be. Somewhere else I read that Lisp got created because McCarthy 
could not get COND into some other language. (Algol?)


-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: Kenny Tilton
Subject: Re: history of conditional expressions
Date: 
Message-ID: <3ECB1101.3020500@nyc.rr.com>
Kenny Tilton wrote:
> 
> 
> Peter Seibel wrote:
> 
>>
>> Anyway, is it fair to say that the modern IF statement in
>> Algol-derived languages such as C, Perl, and Java, is in fact
>> descended from Lisp's COND.
> 
> 
> Could be. Somewhere else I read that Lisp got created because McCarthy 
> could not get COND into some other language. (Algol?)
> 
> 

 From the man himself:

    http://www-formal.stanford.edu/jmc/history/lisp/node2.html

" I invented conditional expressions in connection with a set of chess 
legal move routines I wrote in FORTRAN for the IBM 704 at M.I.T. during 
1957-58. This program did not use list processing. The IF statement 
provided in FORTRAN 1 and FORTRAN 2 was very awkward to use, and it was 
natural to invent a function XIF(M,N1,N2) whose value was N1 or N2 
according to whether the expression M was zero or not. The function 
shortened many programs and made them easier to understand, but it had 
to be used sparingly, because all three arguments had to be evaluated 
before XIF was entered, since XIF was called as an ordinary FORTRAN 
function though written in machine language. This led to the invention 
of the true conditional expression which evaluates only one of N1 and N2 
according to whether M is true or false and to a desire for a 
programming language that would allow its use.

A paper defining conditional expressions and proposing their use in 
Algol was sent to the Communications of the ACM but was arbitrarily 
demoted to a letter to the editor, because it was very short.

.....

In fact, the differentiation program was not implemented that summer, 
because FLPL allows neither conditional expressions nor recursive use of 
subroutines. At this point a new language was necessary...."



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: Chris Riesbeck
Subject: Re: history of conditional expressions
Date: 
Message-ID: <riesbeck-C2E5D3.17322121052003@news.it.northwestern.edu>
In article <················@nyc.rr.com>,
 Kenny Tilton <·······@nyc.rr.com> wrote:

>Kenny Tilton wrote:
>
> From the man himself:
>
>    http://www-formal.stanford.edu/jmc/history/lisp/node2.html
>
>"...A paper defining conditional expressions and proposing their use in 
>Algol was sent to the Communications of the ACM but was arbitrarily 
>demoted to a letter to the editor, because it was very short."

The Algol W compiler at Stanford had conditionals that
could be either expressions or statements. The type,
i.e., expression or statement, of the IF was determined 
by the type of its THEN/ELSE clauses.

There were also expression blocks with the same 
idea. A statement block was a sequence of statements.
An expression block was a sequence of statements
plus an expression. Kind of like PROGN.

I hadn't learned Lisp when I learned Algol W so
the idea that maybe you didn't need to distinguish
statements and expressions didn't occur to me at
the time.