News for hackers. Stuff that matters.
Re:History of Lisp (1979) [pdf] by iamcurious on Monday October 25, 2021 @02:07PM (#28991127)
The invention of the if-expression in page 11 is a gem.
Re:History of Lisp (1979) [pdf] by jimbokun on Monday October 25, 2021 @03:25PM (#28991993)
Heh:

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

Someone should have realized a short letter from John McCarthy is likely more significant than most long papers from other researchers.

Re:History of Lisp (1979) [pdf] by math-dev on Monday October 25, 2021 @04:23PM (#28992663)
Did John Mccarthy invent the IF statement for all languages?
Re:History of Lisp (1979) [pdf] by Jtsummers on Monday October 25, 2021 @04:41PM (#28992860)
The if-expression and if-statement are different things.

if-statements result in conditional execution of different statements, but do not return values themselves. Borrowing C's syntax for if statements the following is not allowed:

  int next = if (odd(current)) { 3*current + 1; } else {current / 2;};
That's not a valid expression in C.

if-expressions return a value, and C does have an if-expression with its ternary operator:

  int next = odd(current)? 3*current + 1 : current / 2;
if-statements are ubiquitous to nearly every programming language. Even when they aren't done with the if keyword and more familiar syntax, even unstructured languages with conditional branching instructions and goto permit you to write something like an if-statement (just disguised by the usually more verbose unstructured form).

if-expressions are less universally available (though I'm unsure of any higher-level-than-assembly language still in popular use that doesn't have an if-expression equivalent).

Re:History of Lisp (1979) [pdf] by codr7 on Tuesday October 26, 2021 @01:06AM (#28996618)
Go doesn't have if-expressions, which makes propagating errors even more painful.
Re:History of Lisp (1979) [pdf] by ggm on Tuesday October 26, 2021 @02:05AM (#28996941)
How does this differ semantically from the C ternary operator? Not syntactically, in its outcome and expression of a testable boolean clause, and a left or right side choice which is the assignment value?
Re:History of Lisp (1979) [pdf] by codr7 on Tuesday October 26, 2021 @06:21PM (#29007110)
Not much.

But syntax matters; a ternary expression tells me at a glance that there's no funny stuff going on, it's just making a choice between two expressions.

In Go I have to scan every single branch when reading to make sure.

Re:History of Lisp (1979) [pdf] by agumonkey on Monday October 25, 2021 @02:30PM (#28991381)
I'm still curious if the if / funarg conversations in the lisp team predated and influenced algol lexical scoping.
Re:History of Lisp (1979) [pdf] by iamcurious on Monday October 25, 2021 @03:14PM (#28991880)
Algol and Lisp were both specified in 1968, but Algol only introduced lexical scoping two years later. So probably yes. I don't have evidence though.
Re:History of Lisp (1979) [pdf] by rwhaling on Monday October 25, 2021 @03:24PM (#28991983)
Algol 60 had lexical scoping in 1960 (while Lisp was in development) and this was known to be equivalent to the lambda calculus by the folks working on it by 1965 or so - https://dl.acm.org/doi/10.1145/363744.363749

I think the consensus is that Scheme was the first Lisp to fully embrace lexical scope, in 1975?

[edited for clarity and punctuation]

Re:History of Lisp (1979) [pdf] by agumonkey on Monday October 25, 2021 @03:32PM (#28992089)
But james slagle issue came before algol was finished, and IIRC some algol document mentions the funarg problem too, so there was crosspollinisation.
Re:History of Lisp (1979) [pdf] by kazinator on Monday October 25, 2021 @07:45PM (#28994688)
There is also the fact that if you have assoc lists, you can trivially easily write a badly performing but correctly lexical lisp interpreter in dynamic lisp, and I suspect this was consciously known. Maybe not enough people cared?
Re:History of Lisp (1979) [pdf] by kazinator on Monday October 25, 2021 @06:42PM (#28994078)
I believe Algol 60 had downward-funarg-only lexical scoping, whereby if you return a function with a captured environment, the coach turns into a pumpkin (unless it is somehow disallowed).

Lambda Calculus specifies the real deal; functions can calculate functions.

Re:History of Lisp (1979) [pdf] by abecedarius on Monday October 25, 2021 @02:58PM (#28991691)
search for 'funarg'
Re:History of Lisp (1979) [pdf] by abecedarius on Monday October 25, 2021 @02:58PM (#28991685)
I found this on page 5 rather than 11.
Re:History of Lisp (1979) [pdf] by iamcurious on Monday October 25, 2021 @03:13PM (#28991854)
Thanks! Page 11 also has a good bit about scoping.