Re: tracing labels in methods

Steve Haflich <[email protected]> Tue, 19 Dec 2006 13:57:25 -0800
Newsgroups gmane.lisp.allegro
Message-ID <16650.1166565445@bach>
   From: Damien Kick <[email protected]>
   Subject:  tracing labels in methods
   Date: Tue, 19 Dec 2006 21:13:37 +0000 (UTC)
   Message-ID:  <[email protected]>
   
   Is it possible to trace location function inside of a method?
   
Remember that internal functions exist as named objects only for
compile functions.  Ypu apparently know this, because you carefully
compile the defun case but miss compiling the method function.

   PG-USER> (defun f ()
              (labels ((%lemma () 69))
                (%lemma)))
   F
   PG-USER> (compile 'f)

   PG-USER> (defmethod g ()
              (labels ((%lemma () 13))
                (%lemma)))
   #<STANDARD-METHOD G NIL>
   PG-USER> (compile 'g)

You have only compiled the generic function g, which is not the same
as the method that belongs to it.  The generic function itself is a
system-generated gf dispatch, and (in this implementation) is always a
copmpiled function.

Here's how to compile an interpreted method function:

 cl-user(2): (defmethod g ()
	       (labels ((%lemma () 13))
		 (%lemma)))
 #<standard-method g nil>
 cl-user(3): (compile '(method g nil))
 (method g nil)
 nil
 nil
 cl-user(4): (trace ((labels (method g ()) %lemma)))
 ((labels (method g ()) %lemma))
 cl-user(5): (g)
  0[2]: ((labels (method g ()) %lemma))
  0[2]: returned 13
 13