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

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

Re: Appending lists


From: Philip Kaludercic
Subject: Re: Appending lists
Date: Wed, 16 Jun 2021 13:01:10 +0000

Jean Louis <bugs@gnu.support> writes:

> * Yuri Khan <yuri.v.khan@gmail.com> [2021-06-16 14:18]:
>> On Wed, 16 Jun 2021 at 16:35, Jean Louis <bugs@gnu.support> wrote:
>> 
>> > What is it doing in background, or underground, does not really matter
>> > for user, what matters is that `x' in following example is changed:
>> 
>> See, that’s your problem: You think there *is* an underground.
>> 
>> Lisp starts with symbols and cons cells and that’s the ground level.
>> It then builds up from that to lists and trees and associative lists.
>> And when you have an associative list binding a symbol to a value,
>> that’s when you get variables, some three floors above the ground.
>
> That is why I leave that to engineers like you. You see, today my
> friend was mentioning how he does not like one but the other webmail
> system. He has no clue about the underlying software, what he wants it
> functionality. 
>
>> And then, when you invoke ‘nreverse’ on a list pointed to by a
>> variable, you, from high up above, can see it scurrying down there and
>> re-routing the ‘cdr’s of the cons cells comprising the list, but not
>> touching the one link from the variable to whatever cons cell had been
>> the first in the list.
>
> I like your smartness, though I would like to have more practical use
> of it. Thomas said that `nconc' does not change `list', unless it is
> special form. And I can practically see this:
>
> (setq list '(A B C)) ⇒ (A B C)
> (nconc list '(1 2 3)) ⇒ (A B C 1 2 3)
> list  ⇒ (A B C 1 2 3)

Change that to

(let* ((list-1 '(a b c))
       (list-2 (nconc list-1 '(1 2 3))))
  (eq list-1 list-2)) ;; => t

and the point should be obvious. This is a confusion on a superficial
level, just like how beginners in C-like languages find it weird that
you can write something like

    x = x + 1

> So maybe he was thinking that symbol `list' does not change, and I
> understood it that variable value does not change.
>
> Why not come back to that and explain me how the variable `list' did
> not change from (A B C) to (A B C 1 2 3)?

-- 
        Philip K.



reply via email to

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