[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setq failure following list manipulation
From: |
Kevin Rodgers |
Subject: |
Re: setq failure following list manipulation |
Date: |
Fri, 21 Apr 2006 15:31:40 -0600 |
User-agent: |
Thunderbird 1.5.0.2 (Windows/20060308) |
Bill Lytton wrote:
> bug or feature?:
>
> quoted arg for setq in function call no longer works after
maninpulating list
> using global variable
>
> (defun ae () (setq nums '(1 2 3)))
> (nconc nums (list 4))
> (ae) ;; returns (1 2 3 4)
> nums ;; returns (1 2 3 4)
I think you meant to call (ae) before (nconc nums (list 4)), since
otherwise nums would not be bound. So, after (ae) nums is bound to
this cons cell structure:
+-+-+ +-+-+ +-+-+
| | +->| | +->| |*|
+++-+ +++-+ +++-+
| | |
v v v
1 2 3
and after (nconc nums (list 4)) the last cons cell is modified so that
the structure (to which nums is still bound) is this:
+-+-+ +-+-+ +-+-+ +-+-+
| | +->| | +->| | +->| |*|
+++-+ +++-+ +++-+ +++-+
| | | |
v v v v
1 2 3 4
--
Kevin Rodgers
Sr. Software Engineer, IHS