[REBOL] Re: Retrieve function name
From: joel:neely:fedex at: 24-Oct-2001 13:35
Peter Carlsson wrote:
> Is it possible to retrieve the name of the function from
> within the function itself? I would appreciate a little
> example if that is possible.
Can you add more detail about what you need to do? The
reason for my dumb question is that functions don't really
have names; one can have anonymous functions, and one can
have many words bound to the same function as their value.
>> do func [x] [x * x] 3
which had no name, or
>> smallpowers: reduce [
[ func [x] [x]
[ func [x] [x * x]
[ func [x] [x * x * x]
[ func [x] [x * x * x * x]
== [func [x][x] func [x][x * x] func [x][x * x * x]
func [x][x * x * x * x]]
which don't have "normal" names, but have accessible references
>> smallpowers/3 5
>> cube: third smallpowers
>> to-the-third: third smallpowers
>> cube 2
>> to-the-third 2
which now has multiple "names" (sort of).
This sentence contradicts itself -- no actually it doesn't.
-- Doug Hofstadter