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

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

RE: [External] : Re: Appending lists


From: Drew Adams
Subject: RE: [External] : Re: Appending lists
Date: Wed, 16 Jun 2021 14:16:50 +0000

> The variable does not change but its value apparently change

What does it mean for a variable's value to change?
Does it mean that the variable points to (returns)
a different value?  Or does it mean that the value
(itself) that it points to, changes?

Put differently, does a variable (itself) change
if it continues to point to the same Lisp object
(thingie) but that object changes?

If variable A evaluates to B at time T1 and later
A evaluates to C, has A's _value_ changed?  Sure.

But there are different ways in which that can
happen, and they can affect what one means.

 (setq A (cons 42 3)) ; A evals to (42 . 3)
 (setq A (cons 6 (cons 7 1))) ; A evals to (6 7 . 1)

That's very different, in terms of Lisp objects,
from this kind of change, though the value of A
is the same as in the previous example.

 (setq A (cons 42 3)) ; A evals to (42 . 3)
 (setcar A 6)
 (setcdr A (cons 7 1)) ; A evals to (6 7 . 1)

In the first case, first A points to one cons,
with car 42 and cdr 3.  Then A points to a
different cons, with car 6 and cdr (7 . 1).

In the second case, first A points to a cons
with car 42 and cdr 4.  Then A points to the
_same_ cons, but that cons now has car 6 and
cdr (7 . 1).

This is Lisp.  Lisp is _not_ a purely
functional language.  It's not even an
impurely functional language, you might say.

If you're using Lisp, it's good to know about
list structure, which (like it or not) is
modifiable.  You may not ever intentionally
modify list structure.  But it helps to be
aware of it.

LISP = LISt Processing language, where "list"
might not mean what you expect.

reply via email to

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