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

MacIvory conversion experience

    Date: Sun, 19 Feb 89 22:08:02 EST
    From: barmar%Think.COM@uunet

    Although I generally use compiled advice in all my patches, I'd rather
    not write code that is dependent on it, so I don't think I'll make use
    of this feature.  For now I'll use the TMC-SELF-ARG subst I wrote.

Someday back in release 6.x i had my own version of permanent advise
(which now is superseded by si:advise-permanently, thanks) in order to
hide site patches from the unsuspecting user at GMD doing a global
unadvise. I simply used DESTRUCTURING-BIND to get access to an advised
functions arguments without knowing where they lived in ARGLIST.

I've extracted the relevant parts of code from an old file. I've tested
it on flavors on both 3600 machines and the XL400 and it seems to be
well behaved. (It allows for an :after type advice to access arguments
too, which might be desirable sometimes to conditionalize an advise) See
the example code at the end of my message.

(Just as I see the usefulness of destructuring-bind in data abstraction
proved again [compare "(car arglist)" to "self"] I wonder why it didn't
make its way into Common Lisp at all! Especially where something like it
must be present in all CL's for defmacro's sake anyway.)


(defmacro 1hidden-advise0 (function class name position 1&body0 forms)
  2"Hide this advice from a global UNADVISE by the unsuspecting user"
0  `(advise ,function ,class ,name ,position
     (destructuring-bind ,(arglist function) arglist ,@forms)))

(defflavor 1foo0 (a b c) ())

(defmethod (1report foo0) (message)
  (format t "~%---> ~A" message))

(hidden-advise (flavor:method report foo) :before test nil (print self) (print message))

(setq i (make-instance 'foo))

(report i "Hello World")