In article <··············@eho.eaglets.com>,
Sam Steingold <···@goems.com> wrote:
>(defclass z () (x))
>(defmethod initialize-instance :after ((a z) &rest junk) ... do something)
>(defun aaa-to-z (a)
> (let ((zz (make-instance 'z)))
> (when ......
> (setf (slot-value z 'x) ....))))
>
>Unfortunately this means that when `initialize-instance :after' is
>invoked, the slot 'x is still unbound. Aparently, I can do
>
>(defmethod initialize-instance :around ((a z) &rest args &key x)
> (unless x (remf args 'x))
> (call-next-method)
> ... do something)
>
>(defun aaa-to-z (x)
> (let ((zz (make-instance 'z 'x (when .... .....))))
> ....))
>
>the problem is that this uses up NIL as a valid value for the slot X.
>
>What is the right way to deal with the problem?
This is why you can provide a supplied-p parameter to go along with
optional and keyword parameters.
(defmethod initialize-instance
:around ((a z) &rest args &key (x nil x-supplied-p))
(when x-supplied-p
(remf args :x))
(call-next-method)
... do something)
--
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.