Scheme functors can be created by extension code. A functor value has the type Scheme_Functor*, a pointer to a record defined by:
typedef struct Scheme_Functor {
Scheme_Type type; /* scheme_functor_type */
short num_imports; /* num expected import args */
short num_exports; /* num exported vars */
Scheme_Object **exports; /* names of exported */
Scheme_Object **export_debug_names; /* used for opening functors; set to NULL */
Scheme_Object *(*init_func)(Scheme_Object **boxes, struct Scheme_Functor *m,
void *debug_request);
Scheme_Object *data;
} Scheme_Functor;
The type field is always scheme_functor_type. The num_imports field specifies the number of variables the functor must import when it is invoked. The num_exports field specifies the number of variables exported by the functor, and exports is array of names (as Scheme symbols). The export_debug_names field should be NULL; opening functors is only supported for the interpreter's internal functors. The data field can be anything.
When the functor is invoked, the init_func function will be called; the array of ``boxes'' passed to this function is an array of variable references for all imported and exported variables, imported variables first. The value of each boxed variable is set or obtained with the SCHEME_PTR_VAL macro. The debug_request argument can be ignored. The return value of the init_func function should be the return value of the functor invocation.
Global variable buckets can be used as variable references. Other variable references can be created with scheme_make_envunbox.