[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About Circular Objects
From: |
Teemu Likonen |
Subject: |
Re: About Circular Objects |
Date: |
Tue, 25 Dec 2012 16:52:27 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.91 (gnu/linux) |
Xue Fuqiao [2012-12-25 16:52:49 +0800] wrote:
> I have a question about the #N# read syntax and #N= syntax. Look at
> this code:
>
> (progn
> (setq x '#1=(a #1#))
> (eq x (cdr x)))
>
> Why does this code return nil? Isn't the second element the list
> itself?
No. It's the CAR of the second cons cell that points to the list itself.
If you want the CDR of the first (and only) cons cell to point back to
the cons cell, you would use this:
(progn
(setq x '#1=(a . #1#)) ; Note the dotted list.
(eq x (cdr x)))
=> t