Re: History of lexical scope in Lisp

Liste des GroupesRevenir à cl lisp 
Sujet : Re: History of lexical scope in Lisp
De : 433-929-6894 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lisp
Date : 16. Mar 2024, 04:37:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240315192646.51@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-03-15, Paul Rubin <no.email@nospam.invalid> wrote:
Does anyone know when lexical scope started appearing in Lisp?  Not
counting Scheme, did it exist in predecessors of Common Lisp?  Was it
used much?  Is it really true that Common Lisp had both lexical and
dynamic scope in order to support older code that was written relying on
dynamic scope and was too hard to convert?

Global variables are dynamically scoped in Common Lisp; the standard
language doesn't provide for global variables that are not dynamically
scoped: "dynamic variable", "global variable" and "top-level variable"
refer to the same thing. Common Lisp's lexical scope design therefore
isn't "total" in a sense; it doesn't provide top-level variables.

New Common Lisp code continues to make use of dynamic scope.

Important predefined variables such as the standard streams (e.g.
*standard-output*) are dynamic variables. By locally binding
*standard-output* we can redirect standard output to a different
stream.

In multithreaded Common Lisp implementations, dynamically scoped
variables provide thread-local storage (as an extension to the
language). If each thread can have its own independent binding of a
dynamic variable, it means that the symbol serves as a key
to a thread-specific storage location.

There are good reasons to use dynamic variables in newly written Lisp
code.

For instance, a context handle (e.g. database handle) that rarely
changes and that is passed around in numerous API calls can be a special
variable, and then it doesn't have to be repated in all those calls.
Yet if it has to take on different values, there is a clean way to do
that.

The aforementioned standard streams are such context handles.  For
instance when we call (write-strin "abc"), the default destination is
*standard-output*; it need not be mentioned, if desired.  The function
will use the current value of the dynamic variable *standard-output*.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
15 Mar 24 * History of lexical scope in Lisp23Paul Rubin
16 Mar 24 +* Re: History of lexical scope in Lisp14Jeff Barnett
16 Mar 24 i`* Re: History of lexical scope in Lisp13Lawrence D'Oliveiro
16 Mar 24 i +- Re: History of lexical scope in Lisp1Kaz Kylheku
16 Mar 24 i `* Re: History of lexical scope in Lisp11Jeff Barnett
16 Mar 24 i  +* Re: History of lexical scope in Lisp9Lawrence D'Oliveiro
17 Mar 24 i  i`* Re: History of lexical scope in Lisp8Jeff Barnett
17 Mar 24 i  i `* Re: History of lexical scope in Lisp7Lawrence D'Oliveiro
18 Mar 24 i  i  `* Re: History of lexical scope in Lisp6Jeff Barnett
18 Mar 24 i  i   +* Re: History of lexical scope in Lisp3Lawrence D'Oliveiro
19 Mar 24 i  i   i`* Re: History of lexical scope in Lisp2Jeff Barnett
19 Mar 24 i  i   i `- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
18 Mar 24 i  i   +- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
19 Mar 24 i  i   `- Re: History of lexical scope in Lisp1George Neuner
16 Mar 24 i  `- Re: History of lexical scope in Lisp1Kaz Kylheku
16 Mar 24 +* Re: History of lexical scope in Lisp4Robert Brown
16 Mar 24 i`* Re: History of lexical scope in Lisp3Lawrence D'Oliveiro
16 Mar 24 i `* Re: History of lexical scope in Lisp2Robert Brown
16 Mar 24 i  `- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
16 Mar 24 +- Re: History of lexical scope in Lisp1Kaz Kylheku
17 Mar 24 +* Re: History of lexical scope in Lisp2Didier Verna
17 Mar 24 i`- Re: History of lexical scope in Lisp1Lawrence D'Oliveiro
19 Mar 24 `- Re: History of lexical scope in Lisp1Johanne Fairchild

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal