Defining a new Scheme type consists mainly to define a new
STk_extended_scheme_type structure and fill in this fields. This
structure is defined as:
Each field of this structure is defined below
[type_name] is a string. It denotes the external name of the new type. The
purpose of this field is mainly for debugging.
[flags] is the union of binary constants. For now, only two constants are defined:
[gc_mark_fct] is a pointer to the function which marks objects of the extended type. The code associated to this function is simple. It consists to call on each field whose type is SCM in the type associated data. This function is automatically called by the interpreter when it scans all the used cells in the GC marking phase. One example of gc_mark_fct is given below.
[gc_sweep_fct] is a pointer to the function which frees the resources allocated for representing the new type of object. This function is automatically called by the GC in the sweeping phase for each cell which is unused.
[apply_function] is a pointer to a function which is called when applying this object to a list of arguments. This function can only be called if the bit EXT_ISPROC is set. The arguments given to this function are evaluated if the EXT_EVALPARAM bit is set. Finally, the environment in which the call is done is passed as the third argument of the apply_function. It serves principally when the EXT_EVALPARAM bit is unset.
Set the apply_function to NULL to use the interpreter default apply function. The default function raises an error when called. You can use the default function when the new type you define is not a function.
[display_fct] is a pointer to a C function which displays objects of the new type. The display function has three parameters. The first parameter is the object to print. The second parameter is the port to which the object must be printed. Printing an object must be done with one of the following functions
The third parameter of the display_fct is a mode constant which can take three different values.