[LISPWORKS][Common Lisp HyperSpec (TM)] [Previous][Up][Next]


5.1.1 Overview of Places and Generalized Reference

A generalized reference is the use of a form, sometimes called a place, as if it were a variable that could be read and written. The value of a place is the object to which the place form evaluates. The value of a place can be changed by using setf. The concept of binding a place is not defined in Common Lisp, but an implementation is permitted to extend the language by defining this concept.

The next figure contains examples of the use of setf. Note that the values returned by evaluating the forms in column two are not necessarily the same as those obtained by evaluating the forms in column three. In general, the exact macro expansion of a setf form is not guaranteed and can even be implementation-dependent; all that is guaranteed is that the expansion is an update form that works for that particular implementation, that the left-to-right evaluation of subforms is preserved, and that the ultimate result of evaluating setf is the value or values being stored.

Access function   Update Function   Update using setf              
x                 (setq x datum)    (setf x datum)                 
(car x)           (rplaca x datum)  (setf (car x) datum)           
(symbol-value x)  (set x datum)     (setf (symbol-value x) datum)  

Figure 5-1. Examples of setf

The next figure shows operators relating to places and generalized reference.

assert                defsetf             push     
ccase                 get-setf-expansion  remf     
ctypecase             getf                rotatef  
decf                  incf                setf     
define-modify-macro   pop                 shiftf   
define-setf-expander  psetf                        

Figure 5-2. Operators relating to places and generalized reference.

Some of the operators above manipulate places and some manipulate setf expanders. A setf expansion can be derived from any place. New setf expanders can be defined by using defsetf and define-setf-expander.

5.1.1.1 Evaluation of Subforms to Places

5.1.1.2 Setf Expansions


The following X3J13 cleanup issues, not part of the specification, apply to this section:


[Starting Points][Contents][Index][Symbols][Glossary][Issues]
Copyright 1996-2005, LispWorks Ltd. All rights reserved.