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

Re: adding side effects to defmethod?

    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.~%")

    (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.