[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "push" creating circular objects
From: |
Nikolaj Schumacher |
Subject: |
Re: "push" creating circular objects |
Date: |
Sat, 23 Aug 2008 13:43:56 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2.50 (darwin) |
Charles Sebold <csebold@gmail.com> wrote:
>> Also, how about consing up the strings with (string ?u ?l) or somesuch
>> to avoid 'em being treated as the same?
>
> I'll give that a try... yeah, that fixed it. I'm surprised I have to do
> this, though. Why are they being treated as the same?
Because they /are/ the same. A string in your code is a constant. A
reference, not a copy, is returned each time.
> Knowing this, I replaced (string ?u ?l) with (copy-sequence "ul") and so
> forth, and got the same result.
>
> Thanks very much for this. But I'm surprised I have to do it.
You don't have to do it. As long as you treat the strings as read-only,
you're fine. It's generally a good idea never to manipulate strings
directly:
(defun get-a-string ()
"ab")
(get-a-string) => "ab"
(aset (get-a-string) 0 ?b)
(get-a-string) => "bb" (!)
regards,
Nikolaj Schumacher
- Re: "push" creating circular objects, (continued)
- Re: "push" creating circular objects, Charles Sebold, 2008/08/21
- Re: "push" creating circular objects, weber, 2008/08/20
- Re: "push" creating circular objects, weber, 2008/08/20
- Re: "push" creating circular objects, Charles Sebold, 2008/08/21
- Re: "push" creating circular objects, xraysmalevich, 2008/08/21
- Re: "push" creating circular objects, Charles Sebold, 2008/08/21
- Re: "push" creating circular objects, Pascal J. Bourguignon, 2008/08/21
- Re: "push" creating circular objects, Charles Sebold, 2008/08/21
- Re: "push" creating circular objects, John Paul Wallington, 2008/08/21