From: Jürgen Böhm
Subject: Lisp 1.5 statical/dynamical scoped ?
Date: 
Message-ID: <427159C5.7FF4E597@gmx.net>
Hello,

  my question goes back to the original Lisp 1.5 as described in the
"Lisp 1.5 Programmer's Manual", especially the interpreter shown there
with the "FUNARG device".

  I always thought that Lisp 1.5 had, what would now be called static
scope, but "A reader" commenting the abovementioned book in amazon.com
remarked, that it gave the classical reference for implementing a
dynamical scoped lisp.
    This left me quite puzzled, especially as I have just changed the
implementation of my own little Lisp-interpreter
(www.aviduratas.de/lisp/prolisp.html) to follow the Lisp 1.5 lines to
get static scope. Who is right now ?

Thanks

Jürgen Böhm

-------------------------------------------------------------------------
Dipl.-Math. Jürgen Böhm           e-mail: reverse: net dot gmx at jboehm 
"At a time when so many scholars in the world are calculating, is it not
desirable that some, who can, dream ?"  R. Thom

From: Pascal Costanza
Subject: Re: Lisp 1.5 statical/dynamical scoped ?
Date: 
Message-ID: <3dd4upF6s4f2lU1@individual.net>
J�rgen B�hm wrote:
> Hello,
> 
>   my question goes back to the original Lisp 1.5 as described in the
> "Lisp 1.5 Programmer's Manual", especially the interpreter shown there
> with the "FUNARG device".
> 
>   I always thought that Lisp 1.5 had, what would now be called static
> scope, but "A reader" commenting the abovementioned book in amazon.com
> remarked, that it gave the classical reference for implementing a
> dynamical scoped lisp.
>     This left me quite puzzled, especially as I have just changed the
> implementation of my own little Lisp-interpreter
> (www.aviduratas.de/lisp/prolisp.html) to follow the Lisp 1.5 lines to
> get static scope. Who is right now ?

Lisp 1.5 is dynamically scoped. For a detailed discussion of how to get 
lexical scoping in an interpreter see "The Art of the Interpreter" by 
Steele and Sussman.


Pascal

-- 
2nd European Lisp and Scheme Workshop
July 26 - Glasgow, Scotland - co-located with ECOOP 2005
http://lisp-ecoop05.bknr.net/
From: Jürgen Böhm
Subject: Re: Lisp 1.5 statical/dynamical scoped ?
Date: 
Message-ID: <42717032.5B8D739F@gmx.net>
Pascal Costanza wrote:
> 
> 
> Lisp 1.5 is dynamically scoped. For a detailed discussion of how to get
> lexical scoping in an interpreter see "The Art of the Interpreter" by
> Steele and Sussman.

  I just thought again over the interpreter described in "Lisp 1.5
Programmers Manual". Indeed it seems to have dynamic scope, but it seems
to be "quite close" to having static scope. If one would replace the
EXPR-value of an atom which is a simple lambda-expression in LISP 1.5
(with possible free variables) by a closure made of a (FUNARG (lambda
(..) ..) env) would LISP 1.5 not become statically scoped (without any
change in the interpreter) ?

    I also looked into the book of Allen, "Anatomy of Lisp" where Allen
says that in Lisp we have the choice of having dynamic binding (by using
QUOTE around functional arguments) or using FUNCTION and the FUNARG
device to achieve static binding (which he calls synonymous to lexical
binding).

  Perhaps you could give some simple code-example which decides what
model applies. I will run it in a modern Common Lisp and in my
Pro(to)Lisp and see what comes out (please excuse my stubbornness !)

Greetings

Jürgen

-------------------------------------------------------------------------
Dipl.-Math. Jürgen Böhm           e-mail: reverse: net dot gmx at jboehm 
"At a time when so many scholars in the world are calculating, is it not
desirable that some, who can, dream ?"  R. Thom
From: Pascal Costanza
Subject: Re: Lisp 1.5 statical/dynamical scoped ?
Date: 
Message-ID: <3de60oF6tcbe2U1@individual.net>
J�rgen B�hm wrote:
> 
> Pascal Costanza wrote:
> 
>>
>>Lisp 1.5 is dynamically scoped. For a detailed discussion of how to get
>>lexical scoping in an interpreter see "The Art of the Interpreter" by
>>Steele and Sussman.
 >
>   Perhaps you could give some simple code-example which decides what
> model applies. I will run it in a modern Common Lisp and in my
> Pro(to)Lisp and see what comes out (please excuse my stubbornness !)

Again, read that paper. It can be downloaded at 
http://library.readscheme.org/page1.html

A simple test case:

(let ((x 5))
   (flet ((f () x))
     (let ((x 10))
       (f))))

If this returns 5, you have lexical scoping. If it returns 10, you have 
dynamic scoping. The dynamic scoping case can seen in the following code.

(let ((x 5))
   (declare (special x))
   (flet ((f () x))
     (let ((x 10))
       (declare (special x))
       (f))))


Pascal

-- 
2nd European Lisp and Scheme Workshop
July 26 - Glasgow, Scotland - co-located with ECOOP 2005
http://lisp-ecoop05.bknr.net/