On 07/05/2011 12:45 AM, Sergey wrote:
Hi all.
Is there a way to get function's name?
(define (fn) ...)
How can I retrieve "fn" inside itself body?
You can use object-name to get the name of a function, if it has one.
> (object-name fn)
'fn
> (object-name (lambda (x) x))
#f
There's no way to ask "what function am I in?"; you have to handle
getting a reference to the function yourself. That's no problem with
defined functions, though, because the function name is in scope within
the function's body:
> (define (fn) (format "I am called ~s." (object-name fn)))
> (fn)
"I am called fn."
Ryan
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users