[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating Modules within C

From: Volkan YAZICI
Subject: Re: Creating Modules within C
Date: Wed, 22 Nov 2006 23:08:22 +0200
User-agent: Mutt/


On Nov 22 06:43, Ludovic Courtès wrote:
> A "module" object is (roughly) little more than a hash table (where
> symbols of global variables are looked up) and a list of modules
> depended on.
> `make-module' is the constructor of module objects: it creates, a new,
> empty module, with no dependencies and where no bindings are defined
> (not even `lambda', `let', etc.)  In turn, `module-use-interfaces!'
> modifies a module (the first argument) in order to have it depend on a
> number of modules (the second and following arguments).
> The term "interface" refers to what a module exposes for use by other
> modules, i.e., what it exports (more precisely, this is the "public"
> interface).

Yeah, I figured those out from ice-9/boot-9.scm and modules.c too.

> And finally, `the-root-module' is, well, the "root" module of Guile,
> i.e., the one that contains all the bindings that are visible "by
> default".
> > I don't want to be lazy but... Can you please explain a bit more about
> > the above usage of modules? For instance, you said, I can bind that
> > [thing] to some variable in C. But then how will I use it?
> Say you have C variable "my_module" bound to a module created as
> explained above.  Then, you can evaluate expression in the context of
> that module as follows:
>   SCM result, expr;
>   expr = scm_list_3 (scm_from_locale_symbol ("+"),
>                      scm_from_int (2), scm_from_int (2));
>   result = scm_eval (expr, my_module);
> This is maybe a bit terse but I hope it helps.

Thanks so much for your kindly help. They all really helped. (As a
proof, see CVS commits of the PL/scheme project. ;-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]