Newsgroups: comp.lang.misc,comp.lang.lisp,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!fas-news.harvard.edu!newspump.wustl.edu!news.ecn.bgu.edu!psuvax1!uwm.edu!news.alpha.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!news.sprintlink.net!EU.net!uknet!festival!edcogsci!jeff
From: jeff@aiai.ed.ac.uk (Jeff Dalton)
Subject: Re: Symbol space in Scheme v. Lisp
Message-ID: <D2z1LE.2Ex@cogsci.ed.ac.uk>
Sender: usenet@cogsci.ed.ac.uk (C News Software)
Nntp-Posting-Host: bute.aiai.ed.ac.uk
Organization: AIAI, University of Edinburgh, Scotland
References: <3g0sah$ssc@agate.berkeley.edu> <3g1an2$cr@mercury.mcs.com> <3g2f2p$90b@Mercury.mcs.com>
Date: Wed, 25 Jan 1995 17:22:25 GMT
Lines: 49
Xref: glinda.oz.cs.cmu.edu comp.lang.misc:20136 comp.lang.lisp:16497 comp.lang.scheme:11853

In article <3g2f2p$90b@Mercury.mcs.com> munyer@MCS.COM (Robert Munyer) writes:
>In article <3g1an2$cr@mercury.mcs.com>, Robert Munyer <munyer@MCS.COM> wrote:
>> In a dynamically scoped Lisp like MACLISP, this will work only if [...]
>
>Actually, to be safe, I should have said EARLY Maclisp.  I think
>that later versions supported lexical scoping in certain situations.

Well, *compiled* MacLisp was lexically scoped, though "lexical
closures" weren't really supported.  (It's possible that there
was a hack that handled functions passed as arguments ("downward
funargs") but not functions returned out of scope as results
("upward funargs").)

But I don't think this was a question of early vs late.  Most Lisp
compilers have provided lexical scoping even when the interpreter
for the same implementation used dynamic scope, and programmers who
didn't "write for the compiler" often had problems when they
eventually tried compiling.  In MacLisp, a variable could be
declared "special" to tell the compiler to make it dynamically 
scoped.

A number of variations are possible.  Franz Lisp, which still exists,
works in the way I've described for MacLisp.  Common Lisp has
"special" declarations but uses the same scoping rules in both
interpreters and compilers.  InterLisp took the opposite approack from
MacLisp: variables were normally dynamically scoped even in compiled
code.  VAX NIL and an IBM 360 Lisp implemented the "partial" lexical
scoping of MacLisp in their interpreter as well as in their compiler.
(Does anyone know whether Lisp/VM continued this practice?)

"Special" comes from Lisp 1.5.  Lisp 1.5 also had "dynamic closures".
That is, you could close over (capture the bindings of) dynamically
scoped variables.  (Think of an interpreter that uses an a-list for
the values of dynamic/special variables.  The closure could just
include the whole current a-list.)  FUNCTION in Lisp 1.5 produced such
a closure and could be used to solve the various scoping problems that
occur when functions are passed as arguments.  (You could also return
such functions as results.)

(In Lisp 1.5, the value of (FUNCTION f) was (FUNARG f a-list),
hence the term "funarg".)

Some MacLisp-related Lisps (and perhaps some versions of MacLisp)
had a form of dynamic closure (ie to hold the bindings of dynamically
scoped variables) for which you had to explicitly list the variables
to "close over".  (So-called fclosures in Franz Lisp are an example.)

-- jd

