All Manuals > Common Lisp Interface Manager 2.0 User's Guide > Appendix C The CLIM-SYS Package

NextPrevUpTopContentsIndex
C.4 Multiple-Value Setf

CLIM provides a facility, sometimes referred to as setf* , that allows setf to be used on "places" that name multiple values. For example, output-record-position returns the position of an output record as two values that correspond to the x and y coordinates. In order to change the position of an output record, the programmer would like to invoke (setf output-record-position) . However, setf only takes a single value with which to modify the specified place. The setf* facility provides a "multiple-value" version of setf that allows an expression that returns multiple values to be used to update the specified place.

defgeneric* [Macro]	

Arguments: name lambda-list &body options

Summary: Defines a setf* generic function named name. The last argument in lambda-list is intended to be class specialized, just as normal setf generic functions are. options are as for defgeneric .

defmethod* [Macro]	

Arguments: name (method-qualifier* specialized-lambda-list &body body)

Summary: Defines a setf* method for the generic function name . The last argument in specialized-lambda-list is intended to be class specialized, just as normal setf methods are. (method-qualifier)* and body are as for defgeneric . For example, output-record-position and its setf* method for a class called sample-output-record might be defined as follows:

(defgeneric output-record-position (record)

(declare (values x y)))

(defgeneric* (setf output-record-position) (x y record))

(defmethod output-record-position ((record sample-output-record))

(with-slots (x y)

(values x y)))

(defmethod* (setf output-record-position)

(nx ny (record sample-output-record))

(with-slots (x y)

(setf x nx

y ny)))

The position of such an output record could then be changed as follows:

(setf (output-record-position record) (values nx ny))

(setf (output-record-position record1)

(output-record-position record2))


Common Lisp Interface Manager 2.0 User's Guide - 3 Mar 2015

NextPrevUpTopContentsIndex