[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: adding side effects to defmethod?
- To: CommonLoops.PA@Xerox.COM
- Subject: Re: adding side effects to defmethod?
- From: Rick.Busdiecker@H.GP.CS.CMU.EDU
- Date: 1 Oct 87 12:39 EDT
- Redistributed: CommonLoops.PA
- Reply-to: Rick.Busdiecker@cs.cmu.edu
From: Rick.Busdiecker@H.GP.CS.CMU.EDU
I want to be able to have a form like:
(defmethod button-pressed ((window x-window) event)
. . .)
have some side-effects . . .
. . . 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.
BTW, If your compiler prints warnings for unused arguments then you'll
notice that PCL/CLOS does some eval-time compilation! Is there any way
to run interpreted? Will there be?
Rick
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; -*- Mode: Lisp; Package: SGF -*-
;;;
(in-package "SGF" :use '("LISP" "CLOS"))
(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))
(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.~%"))