help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FW: [External] : Re: Lexical vs. dynamic: small examples?


From: Drew Adams
Subject: FW: [External] : Re: Lexical vs. dynamic: small examples?
Date: Sun, 15 Aug 2021 15:42:21 +0000

[Was bitten by Reply All not including the list again...]

> > "Dynamic scope" is a misnomer, BTW; it means only that - no
> > particular scope and dynamic extent [...] `let' provides
> > a lexical binding - the scope ends where the `let'
> > ends, lexically.
> 
> But with `let' doesn't the scope end where the let ends even
> for dynamic binding?

No.  Dynamic bindings have indefinite scope - that is,
no particular scope.

The binding has dynamic _extent_ - it lasts _as long as_
(time) the code in the `let' body is executing (which
can include nonlocal exits by that code (or code called
by that code) - e.g. `throw').

For such a variable the `let' does not define a scope;
it only determines which code realizes the binding's
duration.

Scope and extent (duration for referencing) are two
different things.

See the CLTL chapter I pointed to.

> If it isn't only about let, what is it about more?

`let' is not the only construct that can define a
scope.  For example, a function definition (a `defun'
or a lambda) defines the scope of its formal
parameters - they're lexically scoped.

Again, I recommend that CLTL chapter.  It's short, and
it explains things well, including with examples.

<<attachment: winmail.dat>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]