guile-devel
[Top][All Lists]
Advanced

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

Re: Modules: first steps.


From: Marius Vollmer
Subject: Re: Modules: first steps.
Date: 18 Sep 2002 22:41:31 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Han-Wen Nienhuys <address@hidden> writes:

>  * Why set-current-module ?   I'd expect set-current-module!

I can't really say.  I myself have grown a bit tired of the
bang-suffix, I have to say.

>  * How can I get a list of all the variables in a module (ok, I can
>    figure that out by myself, but why is there no API entry for this?)

The module system hasn't completely arrived yet.  (And it is moving
very slowly.)  Most of the things that aren't there have simply not
yet been done.  A lot of stuff is there, but has not been documented
yet since we are not sure if we want to keep it that way it is
currently done.

That being said, we should definitely proceed in small steps.  The big
module system overhaul is not going to happen, as far as I can see.

That being said, there is 'module-for-each' and 'module-map'.  We
should probably just document them and make them official.


>  * It would be nice if the C smob example also touched on module use.

There is "examples/box-module".  Is that what you are looking for, or
something else?

>  * I have in my code:

Here is something similar that does work for me:

    #include <libguile.h>

    void
    ly_init_lily_module (void *unused)
    {
    #if 0
      for (int i=scm_init_funcs_->size () ; i--;)
        (scm_init_funcs_->elem (i)) ();

      if (verbose_global_b)
        progress_indication ("\n");
    #endif

      scm_primitive_load_path (scm_makfrom0str ("lily.scm"));
    }

    void
    ly_init_guile ()
    {
      scm_c_define_module ("lily", ly_init_lily_module, NULL);
    }

    int
    main (int argc, char **argv)
    {
      scm_init_guile ();
      ly_init_guile ();
    }

The reason that you version didn't work is that when
scm_c_resolve_module (and 'resolve-module') can't find the requested
module, it returns a fresh, empty one.  It is _totally_ empty, which
means that things like 'use-modules' aren't available.  Since you want
to define a new module, you should use scm_c_define_module.  It will
do all the right things.

>   * extern void scm_c_use_module (const char *name);.
> 
>     Why is there no scm_use_module (SCM)? For anonymous modules, the
>     storing the name just to use it with scm_c_use_module seems silly,
>     in particular if that function  has to recover the SCM module
>     object from the name again.

Agreed.  We should have that as well.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

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