[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting hold of the method object currently executed
- To: Martin Boyer <firstname.lastname@example.org>
- Subject: Re: Getting hold of the method object currently executed
- From: kanderso@DINO.BBN.COM
- Date: Wed, 15 Nov 89 23:15:48 -0500
- Cc: commonloops.PA@Xerox.COM
- In-reply-to: Your message of Wed, 15 Nov 89 19:18:56 -0500. <8911160018.AA05116@Moe.McRCIM.McGill.EDU>
- Redistributed: commonloops.PA
Date: Wed, 15 Nov 89 19:18:56 EST
From: Martin Boyer <gamin@Moe.McRCIM.McGill.EDU>
Subject: Re: Getting hold of the method object currently executed
> In Victoria Day PCL, is it possible, from the body of a method, to
> reference the method object itself?
> Why do you want this? Loop optimization?
Oh no! I want to be able to "reason" about the method currently being
executed. I have added slots to the standard-method class and made
my methods instances of that new mixin. I can play with methods as
objects, but I need the method object to do this. Hence my query.
So, you want a method to reason about itself while it runs? The both
versions of the code i sent you returns the effective method. Is that
what you want? I don't know how to go from that back to the method to
use its slots from the effective method.
> [...] something like
> (get-method generic-function () (mapcar 'find-class arglist))
> [...] seems to be a waste of time since, being in the body of a method,
> it is obvious that the proper method has just been looked up.
> You could just climb up the stack. Here is Symbolics code:
> (defun current-function ()
> (si:frame-previous-active-frame (si:%stack-frame-pointer))))
> (pcl:defmethod goo (x) (current-function))
Oops! I forgot to mention that it has to be portable at least between
Sun/Lucid and microExplorer.
If somebody has equivalent hooks for these implementations,
I'd be eternally grateful.
> I tried looking for the call-method macro, but it doesn't seem to exist
> in Victoria Day PCL; [...]
> Here is a portable, but slow way to do it.
> (defmethod generic-function-effective-method
> ((gf standard-generic-function) &rest args)
> ;; Returns a function that is the effective method when GF
> ;; is applied to ARGS.
> (cdr (last (apply #'lookup-method-internal gf
> (generic-function-combined-methods gf)
> #'car args))))
Is this faster/better than using the
(get-method generic-function () (mapcar 'find-class args) nil)
I proposed earlier?
Thanks, again, for your kindness,
PS. Please let me know if this discussion should be carried on a private
basis instead of bothering everyone on the mailing list with a marginal
I think this is what the list is for. Everthing is marginal to someone.