Buy GNU books!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
In addition to Scheme code you can also put things that are defined in C into a module.
You do this by writing a small Scheme file that defines the module.
That Scheme file in turn invokes
load-extension to make the
features defined in C available. This works since all definitions
scm_c_define_gsubr etc. go into the current
define-module causes the newly defined module to be
current while the code that follows it is executed.
Suppose we want to put the Bessel function
j0 from the example
extension into a module called
(math bessel). We would have to
write a Scheme file with this contents
(define-module (math bessel)) (export j0) (load-extension "libguile-bessel" "init_bessel")
This file should of course be saved in the right place for autoloading, for example as `/usr/local/share/guile/math/bessel.scm'.
init_bessel is called, the new
(math bessel) module
is the current one. Thus, the call to
put the new definition for
j0 into it, just as we want it.
The definitions made in the C code are not automatically exported from
a module. You need to explicitly list the ones you want to export in
export statements or with the
:export option of
There is also a way to manipulate the module system from C but only Scheme files can be autoloaded. Thus, we recommend that you define your modules in Scheme.
|webmaster||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|