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

Shared slots, and the generality of WITH-ACCESSORS

You should be aware that the output of the function SLOTD-INITFORM is
a _program_ to be run, which will in turn produce the default value.
("program" == "function of 0 arguments").

Similarly, the output of CLASS-DEFAULT-INITARGS (if there be such a
function) would have to be pairings between initarg names (like, :foo)
and programs to be run.

Each and every call to MAKE-INSTANCE might invoke said programs.
The CLOS spec contains very detailed language spelling out just
which subset of such programs will be invoked, depending on the
class definition and the explicitly passed initargs.  But carefully
note the following example:

    (defclass widget () 
      ((frob :initform (progn (punch-paper-tape 3) 15))))

    (loop for i from 1 to 10
          collect (make-instance 'widget))

The loop will return a list of 10 widgets, each with their 'frob'
slots initialized to 15; but 30 feet of paper tape will have been
punched as a side-effect too.

-- JonL --