[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: adding side effects to defmethod?
- To: Rick.Busdiecker@cs.cmu.edu
- Subject: Re: adding side effects to defmethod?
- From: Gregor.pa@Xerox.COM
- Date: Thu, 1 Oct 87 17:10 PDT
- Cc: CommonLoops.PA@Xerox.COM
- In-reply-to: <560104747/rfb@H.GP.CS.CMU.EDU>
- Line-fold: no
Date: 1 Oct 87 12:39 EDT
From: Rick.Busdiecker@H.GP.CS.CMU.EDU
. . . and now I can. Below is some code which shows the general idea.
If there's something grossly unreasonable about the way I've gone about
this, please let me know.
(defclass special-generic-function (clos::generic-function) ()
(:metaclass clos::funcallable-standard-class))
;;; My, but this step simplified things!
(setf (symbol-function 'do-something)
(make-instance 'special-generic-function :name 'do-something))
In the next version of PCL, you will be able to do this by saying:
(ensure-generic-function 'do-something
:generic-function-class 'special-generic-function)
(defmethod add-method ((generic-function special-generic-function) method)
(format t "Some side-effect.~%")
(call-next-method))
(defmethod do-something (some-argument some-other-argument)
(format t "Something.~%"))
Other than that this code is in fact exactly the right way to do this.
All of these generic-functions and classes you are using are in the
current *draft* of the meta object spec.
-------