From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Why doesn't nconc change my variable?
Date: Sun, 05 Oct 2014 19:50:02 +0200 [thread overview]
Message-ID: <87r3ymmmnp.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.10474.1412501757.1147.help-gnu-emacs@gnu.org
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> On 2014-10-05, at 03:59, Pascal J. Bourguignon wrote:
>
>> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>>
>>> Hi list,
>>>
>>> I don't get it.
>>
>> () is actually read as the symbol nil.
>> Symbols are symbols, and not cons cells.
>> You cannot transform a symbol into a cons cell.
>> It is impossible for any function to transform nil into a cons cell.
>>
>> And vice-versa, it is impossible to transform a cons cell into a symbol
>> such as nil. This is the reason why you should also use setf when
>> deleting elements from a list:
>>
>> (setf list (delete e list))
>
> I still don't understand. What if I used (list) to generate an empty
> list instead of () or nil? The results seem to be still the same.
The function list returns nil or a cons.
When it's given no argument, like in (list), it returns nil.
When it's given N arguments, with N>=1, then it returns N new conses,
cdr-linked, with each argument in order stored in the car slots.
So if you used (list) it would make no difference, you'd have to store
the result of delete or of nconc to the variable:
(setf list (delete 42 (list)))
(let ((list (list)))
(setf list (nconc list (list 42)))
list)
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
next prev parent reply other threads:[~2014-10-05 17:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.10460.1412473030.1147.help-gnu-emacs@gnu.org>
2014-10-05 1:59 ` Why doesn't nconc change my variable? Pascal J. Bourguignon
2014-10-05 9:35 ` Marcin Borkowski
[not found] ` <mailman.10474.1412501757.1147.help-gnu-emacs@gnu.org>
2014-10-05 17:50 ` Pascal J. Bourguignon [this message]
2014-10-05 18:04 ` Pascal J. Bourguignon
2014-10-05 1:36 Marcin Borkowski
2014-10-05 1:58 ` Drew Adams
2014-10-05 9:54 ` Marcin Borkowski
2014-10-05 10:52 ` Thorsten Jolitz
2014-10-05 16:29 ` Drew Adams
2014-10-05 16:38 ` Drew Adams
[not found] ` <mailman.10475.1412502895.1147.help-gnu-emacs@gnu.org>
2014-10-05 18:12 ` Pascal J. Bourguignon
2014-10-05 18:14 ` Pascal J. Bourguignon
2014-10-05 18:31 ` Pascal J. Bourguignon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3ymmmnp.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.