[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Shared slots, and the generality of WITH-ACCESSORS
- To: email@example.com
- Subject: Shared slots, and the generality of WITH-ACCESSORS
- From: Jon L White <firstname.lastname@example.org>
- Date: Fri, 23 Mar 90 16:45:56 PST
- Cc: email@example.com, commonloops.pa@Xerox.COM
- In-reply-to: "Peter N. Saurugger"'s message of Fri, 23 Mar 90 14:23:18 CDT <9003232023.AA04600@molbio.cbs.umn.edu>
- Redistributed: commonloops.pa
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 --