[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question about methods
- To: welch@cis.ohio-state.edu
- Subject: Question about methods
- From: Peter Benson <pab@lucid.com>
- Date: Wed, 3 Jan 90 13:20:46 PST
- Cc: commonloops.pa@Xerox.COM
- In-reply-to: Arun Welch's message of Wed, 3 Jan 90 14:02:27 -0500 <9001031902.AA00408@aristotle.cis.ohio-state.edu>
- Redistributed: commonloops.pa
Redistributed: commonloops.pa
Date: Wed, 3 Jan 90 14:02:27 -0500
From: Arun Welch <welch@cis.ohio-state.edu>
Given a method, I'd like to put a wrapper on it such that the result
of calling the method is printed out to *trace-output*. This is
analogous to giving an after advice to a function (at least in the
lisps I'm familiar with). Is there some way for an after method to get
the results of the previous computation, or is the right way to do it
to use an around method as follows:
(defmethod foo :around ((bar some-object))
(prog ((result (call-next-method)))
(print result *trace-output*)
result))
The behaviour I'm looking for would be analogous to
(advise foo :after '(print value *trace-output*))
...arun
In general the closest thing to "the right thing" would probably be:
(defmethod foo :around ((bar some-object))
(let ((results (multiple-value-list (call-next-method))))
(print (car results) *trace-output*)
;; and anything else you want with results
(values-list results)))
This is not perfect because FOO may already have an :AROUND method for
SOME-OBJECTs.
If you know FOO on SOME-OBJECT *ALWAYS* returns one value then your
definition will work.
This is kind of a drag because it clearly conses.