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

Get name of actual function?

 [1/7] from: robert:muench:robertmuench at: 17-Dec-2002 16:21


Hi, is there a way to find out the name of the actual executed function? I would like to trace a call-graph and print out the name of the actual function some how like this: test: func[][ print actual-function-name ] The output should be "test". Robert

 [2/7] 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

 [3/7] from: greggirwin:mindspring at: 17-Dec-2002 11:13


Hi Robert, RMM> Hi, is there a way to find out the name of the actual executed function? RMM> I would like to trace a call-graph and print out the name of the actual RMM> function some how like this: This has come up before, but REBOL dynamic nature doesn't work very well for this. E.g. you can refer to a function by more than one name, call them indirectly, have anonymous functions, etc. I'm not sure what the result of the last go-round on this was, but I think you can't do what you want; not without your own system that parses things and tells when things are evaluated and what they are, which I think only RT can do effectively. -- Gregg

 [4/7] from: maarten:koopmans:surfnet:nl at: 17-Dec-2002 22:12


But you can acces the value of the function, which most of the times is enough. From Joel's bag of tricks, a rerun: a: use [self][self: func [x][do whatever you need with self and your logic]] --maarten

 [5/7] from: robert:muench:robertmuench at: 18-Dec-2002 10:06


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 6>>
> as c or vb may "fix" the relationship between names and > functions at compile time, but that concept doesn't exist in REBOL.
Hi, I expected something like this... Anyway, I'm just seeking for a smart way to track a call-graph without scattering my sources with PRINTs. Unfortunately it doesn't seem to be possible to print line-numbers too. So how do you solve this? Robert

 [6/7] from: info:id-net:ch at: 19-Dec-2002 0:38


I'm interested about how others makes to solve the problem, too. 8-)) Phil

 [7/7] from: ammon:addept:ws at: 18-Dec-2002 17:01


Hi, I have, in the works, a debugger with a trace function for RIDE. I have yet to do performance tests on it, but I am sure I can make it work. I would give you more information on it, but corporate secrets won't allow me to. ;-) I will keep you posted... Enjoy!! Ammon Johnson --- CIO Addept ------------------ (www.addept.ws) 435-616-2322 -------- (ammon at addept.ws)

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted