Function get-setf-expansion

Syntax:

get-setf-expansion place &optional environment vars, vals, store-vars, writer-form, reader-form

Arguments and Values:

place—a place.

environment—an environment object.

vars, vals, store-vars, writer-form, reader-form—a setf expansion.

Description:

7.2.0 75 7.2.0 77Determines five values constituting the setf expansion for place in environment; see Section 5.1.1.2 (Setf Expansions).

Redundat with concept info. \beginlist \itemitem{\bull} A \term{list} of the temporary variables. \itemitem{\bull} A \term{list} of the value \term{forms} to whose values the temporary variables are bound. \itemitem{\bull} A \term{list} of the store variables. \itemitem{\bull} The \term{writer} \term{form}. \itemitem{\bull} The \term{reader} \term{form}. \endlist

\funref{get-setf-method-multiple-value} does not check the number of store variables. The intent of \funref{get-setf-method-multiple-value} is that it be used in cases that allow storing multiple values into a \term{place}. \funref{get-setf-method} takes care of error-checking and macro expansion.

If environment is not supplied or nil, the environment is the null lexical environment.

The consequences are undefined if \param{place} is not a reference to a \term{place}.

Examples:

 (get-setf-expansion 'x)
→ NIL, NIL, (#:G0001), (SETQ X #:G0001), X 

Moon: This is so monumentally confusing that it would be better to remove it. Note that it never uses the store-variables. \code (define-setf-expander multivalue (x) (values '() '() `(,(gensym) ,(gensym)) `(setq ,x 3) '4)) \EV MULTIVALUE (get-setf-expansion '(multivalue dummy-symbol)) \EV NIL, NIL, (#:G0002 #:G0003), (SETQ DUMMY-SYMBOL 3), 4 \endcode

The following example is suspect

;;; This macro is like POP 

 (defmacro xpop (place &environment env)
   (multiple-value-bind (dummies vals new setter getter)
                        (get-setf-expansion place env)
      `(let* (,@(mapcar #'list dummies vals) (,(car new) ,getter))
         (if (cdr new) (error "Can't expand this."))
         (prog1 (car ,(car new))
                (setq ,(car new) (cdr ,(car new)))
                ,setter))))
 
 (defsetf frob (x) (value) 
     `(setf (car ,x) ,value)) → FROB
;;; The following is an error; an error might be signaled at macro expansion time
 (flet ((frob (x) (cdr x)))  ;Invalid
   (xpop (frob z)))
 
;;; The following will modify (cdr z) and not (car z) (macrolet ((frob (x) `(cdr ,x))) (xpop (frob z)))

7.2.0 76 A version of \macref{setf} allowing exactly two \term{subforms}, containing no optimization to remove unnecessary variables, and not allowing storing of multiple values, could be defined by:

\code (defmacro setf (reference value) (multiple-value-bind (vars vals stores store-form access-form) (get-setf-expansion reference) (declare (ignore access-form)) \bq(let* ,(mapcar #'list (append vars stores) (append vals (list value))) ,store-form))) \endcode

Affected By:

None.

Exceptional Situations:

None.

See Also:

defsetf, define-setf-expander, setf

Notes:

Any compound form is a valid place, since any compound form whose operator f has no setf expander are expanded into a call to (setf f).