Function



next up previous contents index
Next: Execution profile Up: Predefined functions Previous: Redefinition

Function

  

Because Smac is an interpreter, a function is a real object and it is possible to access to information about it at run time:

function_name

   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.

function_arg_count

   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().

function_is_builtin

   int function_is_builtin(function)

Returns 1 if the function is a built-in function, else 0.

function_type

   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.

function_list init_function_list

    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):



Lionel Fournigault
Mon Mar 6 13:33:34 MET 1995