[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with CommonLoops



As time goes on PCL is becoming CLOS. Gregor mentioned in his release
message that with-slots has changed to conform to the latest definition.
Although I cannot speak for Gregor or Xerox, there will soon be increased
pressure to conform to CLOS, and people using PCL should be aware that it
will be changing to meet that specification. Such changes cannot be viewed
as ``problems'' with PCL. Here is the latest specification of with-slots:

with-slots							Macro

Purpose:

The macro with-slots creates a lexical context for referring to specified
slots as though they were variables.  Within such a context the value of
the slot can be specified by using its slot name, as if it were a
lexically bound variable.  Both setf and setq can be used to set the value
of the slot.

The macro with-slots translates an appearance of the slot name as a
variable into a call to slot-value.

Syntax:  

with-slots ({slot-entry}*) instance-form body)

slot-entry::= slot-name | (variable-name slot-name)

Examples:

(with-slots (x y)
            position-1
  (sqrt (+ (* x x)
           (* y y))))


(with-slots ((x1 x)
             (y1 y))
            position-1
  (with-slots ((x2 x)
               (y2 y))
              position-2
     (psetf x1 x2
            y1 y2))))


  (with-slots (x y)
              position
    (setq x (1+ x)
          y (1+ y)))

Remarks:

A with-slots expression of the form:

(with-slots (slot-entry1...slot-entryn) instance
   form1...formk)

expands into the equivalent of

(let ((I instance))
  (symbol-macrolet (Q1...Qn)
    form1...formk))

where Qi is 

(slot-entryi (slot-value I 'slot-entryi))

if slot-entryi is a symbol, and is

(variable-namei (slot-value I 'slot-namei))

if slot-entryi is of the form 

(variable-namei slot-namei)

See Also:

symbol-macrolet