Because Smac is an interpreter, a function is a real object and it is possible to access to information about it at run time:
char * function_name(void * function)
Returns the function (built-in or not) whose name is function_name if this one exists, else returns 0. It is used for instance in the edir.sc SmacLib files to load color.sc, if this is not already done.
ATTENTION Be careful, the string is allocated each time the function is called, use free() to release it.
int function_arg_count(function)
Returns the function number of arguments. If the function accepts a variable number of arguments, it returns its minimal number, for instance 1 for printf().
int function_is_builtin(function)
Returns 1 if the function is a built-in function, else 0.
char * function_type(function)
Returns a new allocated string containing the function type.
For instance function_type(function_type)
returns
the following string: "char*(*)(void*)"
.
ATTENTION Be careful, the string is allocated each time the function is called, use free() to release it.
void init_function_list()
void * function_list()
These two functions are intended to access to all the defined
functions (built-in or not).
init\_
function\_
list initializes the iteration, and
function\_
list returns each time a different function or 0
when all the functions have been accessed. For instance, the following
function is defined in the describe.sc file):