Name of the calling function (ISIS/Slang)
		
		
		
		
		
		Jump to navigation
		Jump to search
		
		
	
In SLang a so-called frame specifies the execution of a closed piece of code, e.g., a function. All frames are pushed onto a frame stack and removed once the execution of a particular frame finishes. By accessing this frame stack it is possible to trace back, e.g., a function call.
There are a few functions in Slang available, which allows to receive information about frames (and even variables inside a particular frame!):
- _get_frame_depth
 - _get_frame_info
 - _get_frame_variable
 - _set_frame_variable
 - _use_frame_namespace
 
We can use this to get the name of the parent function, which executes a child function:
define child() {
  variable call = _get_frame_info(_get_frame_depth()-1);
  if (call.function == NULL) { message("I was called from the command line"); }
  else { vmessage("I was called by '%s'", call.function); }
}
define parent() {
  child();
}
This will result in
isis> child(); I was called from the command line isis> parent(); I was called by 'parent'