This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Namespace protection from libguile


I found this in the archives:

        ;;save current module
        (define top (current-module))
        (define x 1)
        x ; yields 1

        ;;create and switch to a new module, called (foo bar)
        (define-module (foo bar))
        (define x 2)
        x ; yields 2

        ;;switch back to the initial module
        (set-current-module top)
        x ; yields 1 again

Of course it doesn't really work, because inside "foo", "top"
will be unbound. But looks like a cool way to achieve namespace
protection.

The questions are: is there a way to make this work on scheme?
(Probably by making "foo" able to access toplevel symbol "top")

And more important, is there a way to make this work on C
(libguile)? Are there functions that do the job of
current-module, define-module and set-current-module?

I really hesitate to use this method because Godot may render it
completely useless, but I do have to use _something_ for now :-)
and this one sounds better than the other sollution someone
offered me (apart from the fact that I lost the message with
this alternative sollution).

[]s,
                                               |alo
                                               +----
--
      I am Lalo of deB-org. You will be freed.
                 Resistance is futile.

http://www.webcom.com/lalo      mailto:lalo@webcom.com
                 pgp key in the web page

Debian GNU/Linux       --        http://www.debian.org