Scheme 48 Manual | Contents | In Chapter: Mixing Scheme 48 and C
Previous: Available facilities | Next: Available facilities

Available facilities

The following facilities are available for interfacing between Scheme 48 and C:

Scheme structures

The structure external-calls has most of the Scheme functions described here. The others are in dynamic-externals, which has the functions for dynamic loading and name lookup from the section on Dynamic Loading, and shared-bindings, which has the additional shared-binding functions described in the section on the complete shared-binding interface.

C naming conventions

The names of all of Scheme 48's visible C bindings begin with `s48_' (for procedures and variables) or `S48_' (for macros). Whenever a C name is derived from a Scheme identifier, we replace `-' with `_' and convert letters to lowercase for procedures and uppercase for macros. A final `?' converted to `_p' (`_P' in C macro names). A final `!' is dropped. Thus the C macro for Scheme's pair? is S48_PAIR_P and the one for set-car! is S48_SET_CAR. Procedures and macros that do not check the types of their arguments have `unsafe' in their names.

All of the C functions and macros described have prototypes or definitions in the file c/scheme48.h. The C type for Scheme values is defined there to be s48_value.

Garbage collection

Scheme 48 uses a copying garbage collector. The collector must be able to locate all references to objects allocated in the Scheme 48 heap in order to ensure that storage is not reclaimed prematurely and to update references to objects moved by the collector. The garbage collector may run whenever an object is allocated in the heap. C variables whose values are Scheme 48 objects and which are live across heap allocation calls need to be registered with the garbage collector.

Previous: Available facilities | Next: Available facilities