Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <20240315192646.51@kylheku.com>
Deutsch   English   Français   Italiano  
<20240315192646.51@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <433-929-6894@kylheku.com>
Newsgroups: comp.lang.lisp
Subject: Re: History of lexical scope in Lisp
Date: Sat, 16 Mar 2024 02:37:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240315192646.51@kylheku.com>
References: <874jd7z5nf.fsf@nightsong.com>
Injection-Date: Sat, 16 Mar 2024 02:37:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1a42fc917c3606d23239d5314488ebcf";
	logging-data="2843346"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19H7vwZONti66XC5uXKEws7WP5wTPrN+1I="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:rq1Wwi9NdekTbQRUMdVqeGar5vY=
Bytes: 2958

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