[Top][All Lists]

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

Re: Basic questions about elisp

From: Pascal J. Bourguignon
Subject: Re: Basic questions about elisp
Date: Sun, 08 Nov 2009 18:12:23 +0100
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

Francis Moreau <address@hidden> writes:

> address@hidden (Pascal J. Bourguignon) writes:
>> Francis Moreau <address@hidden> writes:
>>>>> When I wrote '(2), I suppose the elisp interpreter to create a new
>>>>> list.
>>>> It does so, but at read time.  Not execution time.
>>> Ah ok I see what you mean now.
>>> That's a pretty important point, is this part covered by the elisp info ?
>> Yes.
> Sorry for being blind but I can't find the revelant section.
> Could you give me a pointer ?

Well, there are several places where it's covered, but here is one
where it's explicitely explained:

(info "(elisp)Rearrangement")

 -- Function: nconc &rest lists


     A common pitfall is to use a quoted constant list as a non-last
     argument to `nconc'.  If you do this, your program will change
     each time you run it!  Here is what happens:

          (defun add-foo (x)            ; We want this function to add
            (nconc '(foo) x))           ;   `foo' to the front of its arg.

          (symbol-function 'add-foo)
               => (lambda (x) (nconc (quote (foo)) x))

          (setq xx (add-foo '(1 2)))    ; It seems to work.
               => (foo 1 2)
          (setq xy (add-foo '(3 4)))    ; What happened?
               => (foo 1 2 3 4)
          (eq xx xy)
               => t

          (symbol-function 'add-foo)
               => (lambda (x) (nconc (quote (foo 1 2 3 4) x)))

Of course, it could be infered from:
C-h f quote RET
(info "(elisp)Quoting")

__Pascal Bourguignon__

reply via email to

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