guile-user
[Top][All Lists]
Advanced

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

Namespaces for HB-Guile modules? Help. :(


From: Alejandro Forero Cuervo
Subject: Namespaces for HB-Guile modules? Help. :(
Date: Thu, 15 Nov 2001 18:07:33 -0500
User-agent: Mutt/1.2.5i

I have been working in making it possible and practical to create HB
modules in Guile.  Once I get most of this done, it will be very easy
to create dynamic web functionality programmed in Guile files and have
HB workout the rest.

Basically, you'll be able to load URLs such as
  <http://server.foobar/~azul/whatever.guile/main-page> ,
where whatever.guile is a file programmed entirely in Guile and
main-page is one object defined inside of it.  In whatever.guile
you'll be able to define as many objects (such as main-page) and make
links across of them, define "module-load" and "module-unload"
functions that are called when the "whatever.guile" file is loaded and
unloaded and do many other things.  You'll also be able to combine the
objects defined in Guile files with other HB objects programmed in
Perl or in HB's language (using a :include "whatever.guile"
directive).  You'll obviously be able to keep whatever information you
want in memory across requests.  All of this will be fully integrated
with HB so it'll be ... well, very nice.

Now lets get to my questions...  There are some things I don't fully
understand in Guile's module system.

We could look at HB as an application server, each application
implemented in Guile.  HB loads multiple applications from Guile code
and then resolves a few symbols in them and uses them to attend the
HTTP requests (all of this is completely simplificated and should not
be taken as a statement of what HB does or will do, but it explains
pretty much the problem I'm facing).

For this, I need HB to be able to load different files (one for each
application) into different namespaces.  Each application must come
with a set of standard symbols that are used by the HB process as
entry points into it's (the application's) functionality, but no
application can see the other applications.

For instance, an application might be a file with Guile code,
defining the functions "module-load", "module-unload" and
"module-clean".

By looking at Guile's documentation, it seems that its answer to this
need (different namespaces) is its modules system.

However, it seems that (1) modules need to be on specific locations
designated from them (rather than wherever the users can place them,
usually in the public HTML tree) and (2) the programmer has to fill
their Guile file for a module with lots of special calls to the effect
of defining a new module.

What I need is an API as similar as possible to that of dlopen(3) and
family but for Guile files (rather than shared objects).  So I can do
something like:

  SCM *application, *load_func;

  /* Load a file into its own specific namespace so it won't
   * contaminate Guile's default namespace in any way. */

  application = gh_load_new_namespace(filename);

  /* Now lookup a symbol inside the namespace. */

  load_func = gh_lookup_in_namespace(application, "module-load");

  /* And now exec a given function in a way such that it sees objects
   * in the namespace it was defined in. */

  gh_exec_in_namespace(load_func);

Is this possible with Guile's modules' system?  Or is there something
else I should be using for this rather than modules?

Thank you very much for your help.

Alejo.
http://bachue.com/alejo

--
The mere formulation of a problem is far more essential than its solution.
      -- Albert Einstein.

$0='!/sfldbi!yjoV0msfQ!sfiupob!utvK'x44;print map{("\e[7m \e[0m",chr ord
(chop$0)-1)[$_].("\n")[++$i%77]}split//,unpack'B*',pack'H*',($F='F'x19).
"F0F3E0607879CC1E0F0F339F3FF399C666733333CCF87F99E6133999999E67CFFCCF3".
"219CC1CCC033E7E660198CCE4E66798303873CCE60F3387$F"#Don't you love Perl?

Attachment: pgph0GcgXZviD.pgp
Description: PGP signature


reply via email to

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