Sometimes, it could be necessary to execute some Scheme code from a C function.
If the Scheme function you have to call is a primitive, it is preferred to call
directly the C function which implement it. To know the name of the C function
which implement a Scheme primitive, you'll have to look in the C file primitiveċ which contains the list of all the primitives of the core
interpreter. If the Scheme code you want to execute is not a call to a
primitive, it is generally easier to put your code in a C string and call the C
function STk_eval_C_string. This function takes two parameters: the string
to evaluate and the environment in which evaluation must take place. As for STk_eval, a NIL value for the environment denotes the global
environment. Suppose, for instance, that you have already written in Scheme the
fact procedure; evaluating the factorial of 10 can be done in C with:
This call returns a pointer on a Scheme object (a SCM pointer) containing
the result of the evaluation. If an error occurs during evaluation. It is
signaled to the user and the constant NULL is returned by STk_eval_string.