Hi
From (info "(eieio)Default Superclass"):
- Function: initialize-instance obj &rest slots
Initialize OBJ. Sets slots of OBJ with SLOTS which is a
list of name/value pairs. These are actually just
passed to `shared-initialize'.
But this method effectively receive a list of list. More
precisely a list of a single element, itself a property list of
slots names and values (I'm not sure its the same as "name/value
pairs", which sounds more like an alist to me):
ELISP> (defclass A () ((a :initarg :a)))
[defclass A nil nil ...]
ELISP> (defmethod initialize-instance ((obj A) &rest slots)
(message "Slots: %S" slots))
initialize-instance
ELISP> (make-instance 'A "name" :a 'a)
[object A "name" unbound]
ELISP>
In the echo area:
Slots: ((:a a))
The 'constructor' static method call 'initialize-instance' like
this:
(initialize-instance new-object fields)
Don't we have to use 'apply' here? Like this:
(apply 'initialize-instance new-object fields)
With this fix, we got in the echo area:
Slots: (:a a)
which is IMHO correct. What do you think?
PS: Eric, did you see my previous patch, about 'setf' on a slot
accessor?
--drkm
|