[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Appending lists
From: |
tomas |
Subject: |
Re: Appending lists |
Date: |
Thu, 17 Jun 2021 09:14:48 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Jun 16, 2021 at 09:24:19PM +0000, Philip Kaludercic wrote:
> <tomas@tuxteam.de> writes:
>
> > On Wed, Jun 16, 2021 at 08:36:00PM +0300, Jean Louis wrote:
> >> * Philip Kaludercic <philipk@posteo.net> [2021-06-16 16:07]:
> >> > > (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))))
> > ^^^^ not recommended: '(a b c) is a "constant object"
> > Some version of elisp might even refuse to do that!
>
> True, I wanted to do (list 'a 'b 'c) but I didn't want to change the
> example that much.
That's OK. It works, after all ;-)
I do that all the time, for playing around. But don't do that in
production, that's all.
When publishing as an example, at least, a comment is in order.
In your case, instead of (list 'a 'b 'c), an alternative would
be (copy-sequence '(a b c)).
My comment was there because our current topic is "identity and
mutability", thus it seemed relevant to me. It wasn't to critizice
your code, i /know/ it was just a quick example.
> Also, what versions of elisp wouldn't allow that?
Wait and see :)
I don't think it's planned for now, but I wouldn't exclude it
either, but oh, wait. Have a look at section "E.2 Pure Storage"
of the Emacs Lisp manual. Perhaps there are immutable objects
around, after all :-)
Cheers
- t
signature.asc
Description: Digital signature
- Re: Appending lists, (continued)
- Re: Appending lists, Philip Kaludercic, 2021/06/16
- Re: Appending lists, Emanuel Berg, 2021/06/16
- Re: Appending lists, Jean Louis, 2021/06/16
- Re: Appending lists, tomas, 2021/06/16
- Re: Appending lists, Philip Kaludercic, 2021/06/16
- Re: Appending lists, Emanuel Berg, 2021/06/16
- Re: Appending lists, tomas, 2021/06/17
- Re: Appending lists,
tomas <=
- Re: Appending lists, Emanuel Berg, 2021/06/16
- Re: Appending lists, Emanuel Berg, 2021/06/16
- [OT] Underground (was: Appending lists), tomas, 2021/06/16
- Re: [OT] Underground (was: Appending lists), Emanuel Berg, 2021/06/18
- Re: Appending lists, Emanuel Berg, 2021/06/16
- Re: Appending lists, tomas, 2021/06/16
- Re: Appending lists, Jean Louis, 2021/06/16
- Re: Appending lists, Stefan Monnier, 2021/06/16
- Re: Appending lists, Jean Louis, 2021/06/16
- Re: Appending lists, Emanuel Berg, 2021/06/16