[Top][All Lists]

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

Re: Web Development with Guile in HB

From: Rob Browning
Subject: Re: Web Development with Guile in HB
Date: 17 Jan 2001 15:32:47 -0600
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Alejandro Forero Cuervo <address@hidden> writes:

> For the moment I'll just use a mutex around the code that calls
> Guile to avoid problems with this.  It means dead locks are possible
> (because, depending on the user's code, some of my C functions that
> are callable from Scheme might call others that might want to call
> Scheme again).

Another options would be to just have one and only one thread that
ever calls guile functions and have it waiting on forms to be pushed
onto a FIFO queue for evaluation by other threads which could then
pull the results off of another FIFO result queue.  Of course, you'd
still need mutexes to protect additions to/removals from the queues,
and I don't know enough about your situation to know if this is

> How can I create a new module?  I can't figure out what the
> parameter to scm_make_module should be.  I figured I would ask,
> rather than try with some random values. :)

Well, as you've noticed the C interface to modules has essentially no
documentation, and in my experience doesn't behave as I would have
expected.  As an alternative, you might want to just try something
like this (which I think will work in 1.3.4 and 1.4, but maybe not

  gh_eval_str("(define-module (my module))");
  gh_define("some-function", the-lambda-scm);
  gh_eval_str("(export some-function)");

> I am assuming `modules' means groups of bindings of names to values
> (such as "display" is bound to this procedure, "+" is bound to this
> procedure, "define" is bound to this procedure, stuff (define)d is
> bound to their values and so on).

A module is a namespace, a collection of bindings, none of which are
visible from the outside unless an "outside module" makes a
"use-modules" call naming the given module.  At that point, any
symbols that were "define-public"ed or "export"ed from within the
module will be visible to the module making the use-modules call, but
nothing else.

You'd normally define a module in guile (rather than C) like this:

  (define-module (my module))
  (define xxx 42)
  (define yyy 13)
  (define-public (zzz) (display 'hello) (newline))
  (export xxx)

and then if some other module/file called

  (use-modules (my module))

it would then be able to see xxx and zzz, but not yyy.

Also note that if you're trying to use dynamically loaded modules
(i.e. the whole module is in a shared library -- you'll
probably need to add the trick I've mentioned in one of my other posts
in order to get a "normal" environment where normal guile module
module things like "define", "define-public", etc. will be defined.

Hope this helps.

Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930

reply via email to

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