Author Topic: Function call info  (Read 7027 times)

dmw

  • Senior Community Member
  • Posts: 145
  • Hero Points: 15
Function call info
« on: July 30, 2006, 02:54:18 PM »
Is there any way to programmatically discover the name of a function and the values of its arguments from within the function itself?

I've found a function enticingly called 'trace' in builtins.e, but I can't figure out what it does, if anything.

Dennis

  • Senior Community Member
  • Posts: 3998
  • Hero Points: 521
Re: Function call info
« Reply #1 on: September 22, 2006, 01:59:15 PM »
The name of the function, not really, but the values of it's arguments can be found using arg(n).

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 7041
  • Hero Points: 535
Re: Function call info
« Reply #2 on: September 22, 2006, 03:01:09 PM »
Ah yes, trace().  I added this when I was developing Slick-C.  It allows me to trace the interpreter itself in a debugger.  Place a call to trace() in a macro.  Then set a break point in the debugger on the "ptrace_op()" opcode.  Then start single stepping the interpreter.  Neat trick.

There isn't a way to great way to get the name of the currently running Slick-C function.  Currently, the name for static functions is thrown away when a macro module is loaded.  However, before run-time there are some context tagging functions that can be used to get the current function name.   You can use %\n in an alias to insert the function name in a message maybe for debugging purposes.