guile-user
[Top][All Lists]
Advanced

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

Re: Guile Introspection


From: Issac Trotts
Subject: Re: Guile Introspection
Date: Sat, 7 Jul 2007 17:18:08 -0700

On 7/7/07, Mike Gran <address@hidden> wrote:
Hi-

Is it possible to get introspection information out of Guile
(preferably without having to load GOOPS)?

For example, how can I write a function that prints its own name?

You can define a macro to make this happen:

(defmacro define-named (name-and-args . body)
  (let ((name (car name-and-args))
        (args (cdr name-and-args)))
    `(define (,name ,@args)
      (let ((--function-- ',name))
        ,@body))))

Here is an example of how to use it, analogous to using __FUNCTION__ in gcc:

(define-named (some-fun)
  (display --function--)
  (newline))

Or, what is the scheme version of the following C code

printf("%s %d\n", __FILE__, __LINE__);

I don't know if there's a way to do this in Guile.

Issac


reply via email to

[Prev in Thread] Current Thread [Next in Thread]