Next: , Previous: Low level dynamic linking, Up: Dynamic Libraries


5.16.4.2 Putting Compiled Code into Modules

The new primitives that you add to Guile with scm_c_define_gsubr (see Primitive Procedures) or with any of the other mechanisms are placed into the (guile-user) module by default. However, it is also possible to put new primitives into other modules.

The mechanism for doing so is not very well thought out and is likely to change when the module system of Guile itself is revised, but it is simple and useful enough to document it as it stands.

What scm_c_define_gsubr and the functions used by the snarfer really do is to add the new primitives to whatever module is the current module when they are called. This is analogous to the way Scheme code is put into modules: the define-module expression at the top of a Scheme source file creates a new module and makes it the current module while the rest of the file is evaluated. The define expressions in that file then add their new definitions to this current module.

Therefore, all we need to do is to make sure that the right module is current when calling scm_c_define_gsubr for our new primitives.