On Thu, 23 Jul 2009, Bill Schottstaedt wrote:

> I've googled around and looked through clTl2 but I can't find a way
> in Lisp (scheme) to get the current function name (from an embedded
> macro, for example).  Is there some (non-)standard way to do this?
>

At least in Guile, you can redefine 'define'.
So using a global variable to store the last called
function should work. Untested:

(define last-called-function #f)

(define old-define define)

(define-macro (define def . code)
   (if (pair? def)
       (let ((name (car def)))
         (set! code `((lambda ,(cdr def)
                        (set! last-called-function ',name)
                        (let ()
                          ,@code))))
         (set! def name)))
   `(old-define ,def
                (let ();
                  (set! last-called-function ',name)
                  (let ()
                    ,@code))))

_______________________________________________
Cmdist mailing list
[email protected]
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to