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

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

RE: RE: Understanding the "let" construct and the setting of variables


From: Drew Adams
Subject: RE: RE: Understanding the "let" construct and the setting of variables
Date: Thu, 17 Dec 2020 13:57:12 -0800 (PST)

> > What is correct to say is that the let _binding_ of the
> > variable no longer exists, not that the variable itself
> > no longer exists.
> >
> > In the case of a dynamic variable, it continues to exist.
> > And its binding from the let continues to exist as long
> > as the code in the let body is executing.
> >
> > [Yes, some people will consider a let binding to create
> > a _new_ variable.  In that sense you can say that that
> > var ceases to exist.  But IMO that isn't as clear to
> > users as it is to distinguish the binding from the var.
> > And even if you use the words that way, you still need
> > to point out that the var continues to exist as long as
> > the code within the let body is executing (when the
> > binding is for a dynamic var).]
> 
> I would thing the variable has to be made somewhere.

What's your point?  Yes, you can think of either a variable
being created or a binding being created.  In the case of a
local variable the two amount to different ways of talking
about the same thing.

But in the case of a dynamic variable, it's clearer, and
more common, to talk about a new binding to the same var
being created, rather than a new variable being created.

In particular, a dynamic variable (its latest binding) can
be accessed outside the lexical scope of the let.  It's
natural to think in terms of this in terms of the same var
being bound, rebound, etc. in different ways over time.

> In fact people talk about "unboundp".

An unbound variable is a free variable with respect to
some context.  If a variable has no binding in any
context then it's free/unbound at the top level.

You can use `let' to bind a variable (dynamically or
lexically).  A function parameter gets bound as a local
variable when the function is called.  And `defvar' and
`setq' can assign a value to a variable - that assignment
is also a binding, of sorts.



reply via email to

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