Primitive Syntax

next up previous
Next: Type Extensions Up: libscheme Architecture Previous: Primitive Functions

Primitive Syntax

The user can add new primitive syntax and special forms to libscheme. A libscheme syntax form is implemented as a C function that takes two arguments, an expression and an environment in which the expression should be evaluated. The form is passed directly to the syntax form with no evaluation performed. This allows the syntax primitive itself to evaluate parts of the form as needed. Figure 7 shows the implementation of the if special form. Note that if cannot be implemented as a procedure because it must not evaluate all of its arguments. The scheme_eval() function evaluates a libscheme expression with respect to a particular environment.

Figure 7: The if special form

C functions that represent syntax forms are turned into Scheme objects by passing them to the scheme_make_syntax() procedure which returns a new object of type scheme_syntax_type.

Brent Benson
Mon Sep 19 16:03:14 EDT 1994