Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Procedures   [Contents][Index]

6.9.2 Primitive Procedures

Procedures written in C can be registered for use from Scheme, provided they take only arguments of type SCM and return SCM values. scm_c_define_gsubr is likely to be the most useful mechanism, combining the process of registration (scm_c_make_gsubr) and definition (scm_define).

Function: SCM scm_c_make_gsubr (const char *name, int req, int opt, int rst, fcn)

Register a C procedure fcn as a “subr” — a primitive subroutine that can be called from Scheme. It will be associated with the given name but no environment binding will be created. The arguments req, opt and rst specify the number of required, optional and “rest” arguments respectively. The total number of these arguments should match the actual number of arguments to fcn, but may not exceed 10. The number of rest arguments should be 0 or 1. scm_c_make_gsubr returns a value of type SCM which is a “handle” for the procedure.

Function: SCM scm_c_define_gsubr (const char *name, int req, int opt, int rst, fcn)

Register a C procedure fcn, as for scm_c_make_gsubr above, and additionally create a top-level Scheme binding for the procedure in the “current environment” using scm_define. scm_c_define_gsubr returns a handle for the procedure in the same way as scm_c_make_gsubr, which is usually not further required.