help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About self-referential object


From: Pascal J. Bourguignon
Subject: Re: About self-referential object
Date: Sat, 05 Jan 2013 00:40:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Xue Fuqiao <xfq.free@gmail.com> writes:

> I have a question about self-referential object:
>
> (setq foo '(nil))
> => (nil)
> (setcar foo foo)
> => (#0)
>
> It is an infinite recursion.  What does the `#0' mean here?  Can anybody 
> help?  Thanks.

It means you've commited the sacrilege of modifying a literal value!
If you modify a mutable cons cell, everything works as expected:


*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (setq print-circle t)
t
ELISP> (setq foo (cons nil nil))
(nil)

ELISP> (setcar foo foo)
#1=(#1#)

ELISP> 
-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]