Re: using setf with assoc
- From: "Steven M. Haflich" <smh@xxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 04:57:32 GMT
Jimka wrote:
I noticed that (setf (assoc key alist) newvalue) fails, and in sbcl I get the following warning: ; The function (SETF ASSOC) is undefined, and its name is reserved by ANSI CL so ; that even if it were defined later, the code doing so would not be portable.
Does anyone know why this is not implemented? Is it because noone could agree about what it would do? Or does it really not make sense in the first place?
It does not make sense:
setf of assoc is not specified in the ANS because there is no way to specify it that would be consistent with the language conventions.
- It is required that a setf return the new value stored into the <place>. - assoc returns a cons of a key and value. A cons is not reasonably defined as a place. You could, I suppose, have the setf method accept a fresh cons, but other code could have previously retrieved and cached that cons from the alist, so providing a new cons would violate the venerable semantics of alists. Once a key is consed onto an alist, that cons object remains unless explicitly removed from the alist.
If you don't understand this you're not quite ready to write setf methods. .
- References:
- using setf with assoc
- From: Jimka
- using setf with assoc
- Prev by Date: Re: type systems as libraries
- Next by Date: Re: type systems as libraries
- Previous by thread: Re: using setf with assoc
- Next by thread: split-sequence
- Index(es):
Relevant Pages
|
|