Author Topic: Function call info  (Read 4777 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

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2881
  • Hero Points: 435
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: 5041
  • Hero Points: 418
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.