From: Adam Warner
Subject: nconc and nil
Date: 
Message-ID: <pan.2003.04.08.01.02.06.61917@consulting.net.nz>
Hi all,

If one is performing destructive modification on a list should one define
an empty list using (list) instead of nil?

;;wrong/undefined modification of a literal?
(defparameter *list* nil)
(setf *list* (nconc *list* ...)

;;right?
(defparameter *list* (list))
(setf *list* (nconc *list* ...)

Thanks,
Adam

From: Paul F. Dietz
Subject: Re: nconc and nil
Date: 
Message-ID: <tdudnXV5y9FVvw-jXTWc3A@dls.net>
Adam Warner wrote:
> Hi all,
> 
> If one is performing destructive modification on a list should one define
> an empty list using (list) instead of nil?


The value of (list) *is* nil.  These two forms denote the same object.

	Paul
From: Adam Warner
Subject: Re: nconc and nil
Date: 
Message-ID: <pan.2003.04.08.01.23.48.177084@consulting.net.nz>
Hi Paul F. Dietz,

>> If one is performing destructive modification on a list should one
>> define an empty list using (list) instead of nil?
> 
> The value of (list) *is* nil.  These two forms denote the same object.

Yeah, but in the parallel universe of my mind one could be the copy of the
unique symbol nil. Any flimsy evidence that (eq (list) nil) => t will be
dismissed with extreme prejudice.

Have fun,
Adam
From: Joe Marshall
Subject: Re: nconc and nil
Date: 
Message-ID: <d6jx9lj6.fsf@ccs.neu.edu>
"Adam Warner" <······@consulting.net.nz> writes:

> Yeah, but in the parallel universe of my mind one could be the copy of the
> unique symbol nil. 

`Copy' of a `unique' symbol?
From: Adam Warner
Subject: Re: nconc and nil
Date: 
Message-ID: <pan.2003.04.08.13.34.03.616297@consulting.net.nz>
Hi Joe Marshall,

>> Yeah, but in the parallel universe of my mind one could be the copy of the
>> unique symbol nil. 
> 
> `Copy' of a `unique' symbol?

Glad you got the joke Joe.
From: Joe Marshall
Subject: Re: nconc and nil
Date: 
Message-ID: <vfxp84ix.fsf@ccs.neu.edu>
"Adam Warner" <······@consulting.net.nz> writes:

> Hi Joe Marshall,
> 
> >> Yeah, but in the parallel universe of my mind one could be the copy of the
> >> unique symbol nil. 
> > 
> > `Copy' of a `unique' symbol?
> 
> Glad you got the joke Joe.

Given enough time I can see the most obvious of things.
From: Kent M Pitman
Subject: Re: nconc and nil
Date: 
Message-ID: <sfwd6jxx02x.fsf@shell01.TheWorld.com>
"Adam Warner" <······@consulting.net.nz> writes:

> If one is performing destructive modification on a list should one define
> an empty list using (list) instead of nil?
> 
> ;;wrong/undefined modification of a literal?
> (defparameter *list* nil)
> (setf *list* (nconc *list* ...)
> 
> ;;right?
> (defparameter *list* (list))
> (setf *list* (nconc *list* ...)

There is only one NIL.  NIL is not a cons, and so does not get changed.

Read the definition of NCONC.

(nconc nil . lists) ==  (nconc . lists)
From: Adam Warner
Subject: Re: nconc and nil
Date: 
Message-ID: <pan.2003.04.08.01.19.42.691851@consulting.net.nz>
Hi Kent M Pitman,

> There is only one NIL.  NIL is not a cons, and so does not get changed.
> 
> Read the definition of NCONC.
> 
> (nconc nil . lists) ==  (nconc . lists)

Thanks Kent. Now I understand why I have never seen this idiomatic use of
(list) (other than in my recent code :-)

Regards,
Adam