[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using setq to create lists based on other lists...
From: |
Robert Thorpe |
Subject: |
Re: using setq to create lists based on other lists... |
Date: |
Sun, 02 Dec 2018 19:11:28 +0000 |
I agree with you on some things and I disagree with you on others.
Notice also it says this in the Emacs Lisp intro in the node "Using
setq":
> Although I have been using the term ‘assign’, there is another way of
> thinking about the workings of ‘set’ and ‘setq’; and that is to say
> that ‘set’ and ‘setq’ make the symbol _point_ to the list. This
> latter way of thinking is very common and in forthcoming chapters we
> shall come upon at least one symbol that has ‘pointer’ as part of its
> name. The name is chosen because the symbol has a value, specifically
> a list, attached to it; or, expressed another way, the symbol is set
> to “point” to the list.
It also says in the section on setcar:
> As you might guess from their names, the ‘setcar’ and ‘setcdr’
> functions set the CAR or the CDR of a list to a new value. They
> actually change the original list, unlike ‘car’ and ‘cdr’ which leave
> the original list as it was.
...
> Put another way, the variable ‘animals’ points to the list ‘(antelope
> giraffe lion tiger)’.
In the section "How Lists are Implemented" it describes how things work
internally.
So, I think you could have avoided your first problem if you'd read the
intro more carefully.
However, you're quite right in what you wrote most recently...
>> You're using `setq` on vars you haven't declared/defined yet!
>
> The Introduction doesn't even mention that...
It doesn't. It mentions setq, let and defvar. But it never says that
it's the preferred style to define variables with let & defvar first. I
think it should say that.
I've seen lots of beginners write programs that setq undefined symbols
and now I know why.
>> Better write this as (setf (nth 3 myDateLastMonth) myDay)
>
> No reference to setf in the Introduction, and it's buried under tons of
> reference in the Reference...
I agree here too. I think setf is important enough that the introduction
should mention it at least in passing.
BR,
Robert Thorpe
- using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Stefan Monnier, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Stefan Monnier, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Stefan Monnier, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists...,
Robert Thorpe <=
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
Message not available
- Re: using setq to create lists based on other lists..., Barry Margolin, 2018/12/02
- Re: using setq to create lists based on other lists..., Stephen Berman, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Stephen Berman, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Michael Heerdegen, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Michael Heerdegen, 2018/12/02