Hi,
Mike Gran <[EMAIL PROTECTED]> writes:
> For example, how can I write a function that prints its own name?
In Scheme, functions are first-class objects that are not necessarily
bound to a top-level name. For instance, a `lambda' is nameless:
(lambda args
...)
Thus, there is no generic, portable way to find the symbol under which a
procedure is bound (_if_ it's bound). But...
> Or, what is the scheme version of the following C code
In Guile, "primitive procedures" (i.e., procedures written in C) have
their "official" name recorded in them. For instance:
guile> 1+
#<primitive-procedure 1+>
guile> (procedure-name 1+)
1+
Happily, it also works with regular procedures defined with `define':
guile> (define (f x) x)
guile> (procedure-name f)
f
... but doesn't work with lambdas:
guile> (procedure-name (lambda args args))
#f
As for the file name and line number, you can in theory get them
(provided Guile runs in "debug" mode) using `procedure-source' and
`source-properties', although the details escape me now.
Thanks,
Ludovic.
_______________________________________________
Guile-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/guile-user