Evaluating arguments

In some circumstances it could be useful to add new primitives which don't evaluate their arguments. This permits to add new control structures to the interpreter. To illustrate this, we will add two new primitives to the interpreter: when and unless. As explained in the preceding section, the C functions which will implement those control structures must be of type tc_fsubr. A tc_fsubr primitive, on the C side, is given three parameters when called:

  1. a list of its (non evaluated) parameters,
  2. the local environment when it was called (and in which evaluations should generally take place),
  3. the length of the parameters list.

The C function can step through its parameter list using the C macros CAR, CDR and NULLP (which do the obvious work) and evaluates elements of this list as needed. Evaluation of an expression can be done with the STk_eval C function. STk_eval takes two parameters: the expression to evaluate and the environment in which evaluation takes place (the NIL variable, by convention, denotes the Indexglobal environment).



Subsections