Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Get name of actual function?

From: joel::neely::fedex::com at: 17-Dec-2002 11:34

Hi, Robert, This is a question that comes up every now and then. Functions don't have "actual names". Legacy languages such as c or vb may fix the relationship between names and functions at compile time, but that concept doesn't exist in REBOL. The other side of the coin is that you could add a /name refinement to a function you are defining yourself; that refinement could return whatever value you wish, for whatever purpose you wish. See below for standard rant. ;-) -jn- Robert M. Muench wrote:
> Hi, is there a way to find out the name of the actual executed function? > > test: func[][ > print actual-function-name > ] > > The output should be "test". Robert >
What if we had this? gleep: florp: test: func[][ print actual-function-name ] Then what if any one (or more) of those words (GLEEP, FLORP, or TEST) were redefined? Since functions are first class *values* in REBOL, asking a function What variable(s) currently refer to you? is just as (not) meaningful as asking the integer 2 the same question. In addition, it is quite possible to have (and use) a function when there is *no* answer to that question (there are no variables/words/names for the function). What if we had this? do pick reduce [ func [] [ print actual-function-name print "Two" ] func [] [ print actual-function-name print "Four" ] func [] [ print actual-function-name print "Eight" ] func [] [ print actual-function-name print "Sixteen" ] ] 2 There are no user-defined words at all in the above, yet it can be evaluated with no problem in REBOL (if we provide some definition for the word ACTUAL-FUNCTION-NAME, that is... ;-). -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446