Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A very ... let me say, ahistorical rant, starting at the very beginning:

"Lisp gets lexical scope right, for example, simply because we have a head start of decades over the [line out]competition[/line out] others."

Case in point: LISP didn't get this right in 1958 while apparently in the same year (as I read Wikipedia) ALGOL did. This caused a lot of grief which wasn't resolved until 1983 when Common Lisp adopted Scheme's ALGOL inspired lexical scoping. And Emacs Lisp and AutoLISP (AutoCad), two very big (in terms of real world usage) Lisps are dynamically scoped.

Lisp has much to be proud of, but this could easily be the single worst aspect of it historically.



ALGOL did, but it had it easy, because it was not providing closures and garbage collection. When ALGOL had lexical scoping, these things were unresearched. It took a while in the Lisp and FP community to solve this (see the FUNARG problem).


LISP wasn't providing closures at that point (1958), was it?

I've read that the LISP community was the only major part of the FP community that had trouble with this and that the other parts were always confused about why this caused such consternation with LISP.


No language had lexical closures in 1958. ALGOL had lexical scope, but not closures. So their part was easy. On a language level all the consequences were explored with Scheme in the 70s. Before that their were individual solutions found to create closures.

Read the history of the FUNARG problem (1970).

FP languages came up later. The first ML appeared in something like 1972/1973. I'm not sure if that had lexical closures. I doubt that. The Lisp community was one active part of the FP community that detected the problem and eventually found a solution. Scheme was the first language to demonstrate that (1975). Other FP languages also went that route (ML, where the first ML was implemented on top of Lisp, IIRC). The MacLisp branch took some time to adopt lexical closures. First a special construct was introduced to create a closure. In some other implementations the compiler was using lexical scope, but not the interpreter. Common Lisp was then in 1984 the next major Lisp dialect that settled for lexical scope (incl. closures) for both interpreted and compiled code.

The Lisp community (other than Scheme) had substantial code at the end of the 1970s, so there was some reluctance to move to lexical closures. Lexical closures also made the implementation a bit more difficult. The interpreter is simpler without them. There were also performance issues to overcome.


This seems to be exactly what the author is talking about. Lisp gets lexical scope right exactly because it did it wrong for about 20 years.


I'm not sure I would agree, however I'm not familiar enough with Common Lisp's lexical scoping to be absolutely sure (actually, I've never programed in a lexically scoped Common Lisp, just an early IBM-PC interpreter that was dynamic, and that for only a few months).

Common Lisp seems to be missing a number of things I like in Scheme for this sort of thing; my impression is that for understandable reasons the introduction of lexical scoping to mainline Lisp in Common Lisp was done with an eye towards minimal breakage of all that great software that had been developed in the previous 25 years.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: