This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: a module spanning a .c and a .scm file
- To: Shawn <sabetts at vcn dot bc dot ca>
- Subject: Re: a module spanning a .c and a .scm file
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 27 Jul 2000 15:51:37 +0200
- Cc: guile at sourceware dot cygnus dot com
- Cc: djurfeldt at nada dot kth dot se
- References: <20000727002129V.sabetts@vcn.bc.ca>
- Reply-To: djurfeldt at nada dot kth dot se
Shawn <sabetts@vcn.bc.ca> writes:
> I have figured out how to create a module in scheme with
> (define-module ...) and I can create a module in c with
> scm_register_module_xxx. Is there a way I could have a module span .c
> and .scm files? That is, I have some functions for a module defined in
> a .scm file and others defined in .c file, how could I load them all
> with one
>
> (use-modules (i-dig the-modules))
>
> I tried just dynamically linking the c functions and calling an
> scm_init_the_module function from within the .scm file, which sorta worked
> except that I couldn't access any of the scm functions from the c
> library. I'm guessing they weren't added the same way a (define-public
> ...) procedure is added.
Here is how GOOPS achieves to have mixed C and Scheme in the module
(oop goops):
1. Create a dynamically loadable library called libgoopscore which
registers the module (oop goops goopscore) using
scm_register_module_xxx, and place a link to the .la file on the
load path.
2. Create a Scheme module goops.scm starting with
(define-module (oop goops)
:use-module (oop goops goopscore)
...)
3. Switch to the (oop goops) module in the init function for the
goopscore module. (Please refer to guile-oops/goops.c.)
(This problem will get a final solution with the new module system.)