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

Function

  

Because 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.

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 instancefunction_type(function_type) returns the following string: "char*(*)(void*)".

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). initfunctionlist initializes the iteration, and functionlist 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):


tabular1846


Lionel Fournigault
Wed Apr 30 10:44:37 MET DST 1997