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

Richard Stallman gave an excellent use and rationale for dynamic scope in the EMACS manual:

http://www.gnu.org/software/emacs/emacs-paper.html#SEC17

One of my favourite things about perl and CL is the ability to have lexical (my/let) and dynamic (local/special) scope in the same program depending on what is clearer.

In fact, it comes up often enough that programming in a language lacking dynamic scope (e.g. basic, JavaScript, or python) feels limiting sometimes, and I end up emulating it (settings+extend, observables, etc).



That rationale may be a bit revisionist, here is Olin Shivers' take on RMS's justification for elisp's dynamic scoping:

"Some context: Common Lisp did not exist (the effort was just getting underway). MIT Scheme did not exist. Scheme was a couple of AI Lab tech reports and a master's thesis. We're talking the tiniest seed crystal imaginable, here. There was immense experience in the lisp community on optimising compiled implementations of dynamically-scoped languages -- this, to such an extent, that it was a widely held opinion at the time that "lexical scope is interesting, theoretically, but it's inefficient to implement; dynamic scope is the fast choice." I'm not kidding. To name two examples, I heard this, on different occasions, from Richard Stallman (designer & implementor of emacs lisp) and Richard Fateman (prof. at Berkeley, and the principal force behind franz lisp, undoubtedly the most important lisp implementation built in the early Vax era -- important because it was delivered and it worked). I asked RMS when he was implementing emacs lisp why it was dynamically scoped and his exact reply was that lexical scope was too inefficient. So my point here is that even to people who were experts in the area of lisp implementation, in 1982 (and for years afterward, actually), Scheme was a radical, not-at-all-accepted notion. And outside the Lisp/AI community... well, languages with GC were definitely not acceptable. (Contrast with the perl & Java era in which we live. It is no exaggeration, thanks to perl, to say in 2001 that billions of dollars of services have been rolled out to the world on top of GC'd languages.)"

http://www.paulgraham.com/thist.html

(emphasis not my own)

That whole page is a good read, particularly if you are a fan of Shivers' writing style.


Cool, I hadn't read Olin's take.

However, the cited rationale can't really be revisionist of what RMS told Olin, because it was published in 1981, about 14 months before Olin came to MIT in 1982.

It appears verbatim in RMS's paper, "EMACS: The Extensible, Customizable, Self-Documenting Display Editor," A.I. Memo 519a, ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-519A.pdf (March 26, 1981). He doesn't mention an efficiency justification in there.

The whole document is also fascinating for including RMS's nascent but not-fully-baked early thinking about free software.


Hmm, good catch, I didn't notice when that was published.




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

Search: