guile-user
[Top][All Lists]
Advanced

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

Re: the module system ?


From: Mikael Djurfeldt
Subject: Re: the module system ?
Date: 07 Mar 2001 15:18:17 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Ian Grant <address@hidden> writes:

> > > as you see, it works perfectly fine, so why does it not work from a
> > > guile listener?
> > 
> > Scripts run in a different module (guile) from the module for
> > interactive use (guile-user).  The reason is that the environment for
> > interactive use is augmented with bindings for debugging, procedure
> > documentation etc.  We don't want to load all of that for scripts,
> > because we want startup time to be as small as possible.

[...]

> The idea being that I avoid having to explicitly list all the C
> module exports by running the C module init function in the current
> module.  It's not entirely clear to me why this fails in David's
> case though.

OK, you're correct that this is the bug.

In the script case, the "current module" is the root module and the C
bindings become exported to all modules.  (Scripts should of course
*not* run in the root module.  They should have their own
(guile-script) or something...)

So in that case, things happens to work.

For interactive use, the bindings end up in the (guile-user) module
and aren't accessible in the module which tries to import them.


Which module is the "current module" before the `define-module' form
is undefined.  Furthermore, remember that several modules might want
to use the bindings.

Currently, re-exporting the bindings explicitly is one solution.
Another would be to initialize the C bindings inside a module
(database postgrescore) or something, using the preliminary module
system API in libguile/modules.c, and add that module to the use-list
of the public interface of (database postgres):

(define-module (database postgres)
  ...
  :use-module (database postgescore)
  ...)

(set-module-uses! %module-public-interface
                  (nested-ref the-root-module
                              '(app modules database postgrescore)))


I hope to, within shortly, resume the "new module system process" so
that we can find better ways to express things like this.


Meanwhile, could you suggest to David how to fix his problem?

Best regards,
/mdj



reply via email to

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