This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Safe Guile?
- To: orre at nada dot kth dot se (Roland Orre)
- Subject: Re: Safe Guile?
- From: Jost Boekemeier <jostobfe at linux dot zrz dot TU-Berlin dot DE>
- Date: 18 Nov 1999 00:00:09 +0100
- Cc: "Marisha Ray & Neil Jerram" <mpriz at dircon dot co dot uk>, Olivier dot Buechel at unifr dot ch, knotwell at f5 dot com, guile at sourceware dot cygnus dot com
- References: <199911171340.OAA26415@faun.nada.kth.se>
Roland Orre <orre@nada.kth.se> writes:
> Roland Orre <orre@nada.kth.se> writes:
> > Will this behaviour possibly change (Jost?) ?
>
> Jost Boekemeier <jostobfe@calvados.zrz.TU-Berlin.DE> writes:
> > Doesn't `(module (my module) (import ))' or
> > (define-module (my module))
> > (module-import )
> > do what you want?
>
> Roland Orre <orre@nada.kth.se> answers:
> No, at the moment there is no simple way to avoid getting all definitions
Yes, sorry. I tried to answer the question if that behaviour will
change. If you want to take a look at the new module code (or want to
CONTRIBUTE :), do the following:
1. Check out guile-core dated 09/07/99
cvs -z 9 -d :pserver:anoncvs@egcs.cygnus.com:/cvs/guile co -D 1999-09-07 guile-core
2. Apply the patches from http://www.user.tu-berlin.de/~jostobfe/
cd guile-core/..
patch -p0 <./ice-9.patch
patch -p0 <./libguile.patch
patch -p0 <./readline.patch
3. Compile it as normal e.g.:
CFLAGS="-g -O0 -static" ./configure --prefix=/var/tmp/guile-test
make install
After that you can create a new module as follows:
(module-create (my module)) ;; returns the module signature of (my module)
(go (my module)) ;; same as (module-go (module-access (my module)))
(module (my module) ;; change my module's interface to:
(import (ice-9 root) (ice-9 debug))
(export car caar)
(public ))
or, if you prefer the old syntax:
(define-module (my module))
(module-import (ice-9 root) (ice-9 debug))
(export car caar)
Strictly speaking `(module (my module) ...)' is not a module but the
module's interface.
Now test (my module) by creating a test-module (my test):
my/module> (module-go (module-create (my test)))
my/test> (environment-fold (the-environment)
(lambda (sym val rest)
(display "---> ")
(write-line sym)) #f)
---> scm-repl-prompt
---> the-module
my/test> (define goodbye exit)
my/test> (define scm-repl-prompt "say goodbye! ")
;; restrict the import list to `(my module)'
say goodbye! (module-import (my module))
say goodbye! define -> error
say goodbye! define-module -> error
say goodbye! exit -> error
say goodbye! environment-fold -> error
(goodbye)
()
my/module> (define module-sig-of-module-my-test (module-access (my test)))
my/module> module-sig-of-module-my-test
#(#<eval environment 401b8cb0> #f #f my/ my/test)
;; reset the import list for module `(my test)'.
;; `module-import-proc' is the procedure called by the `module-import' macro
my/module> (module-import-proc module-sig-of-module-my-test '((ice-9 root)))
my/module> (module-go module-sig-of-module-my-test) ;; same as `(go (my test))'
;; module-go has created a new repl for module my/test: scm-repl-prompt
;; and the-module are reset to their default values
my/test> scm-repl-prompt
"my/test> "
my/test> (the-module)
#(#<eval environment 401b8cb0> #f #f my/ my/test)
;; interned symbols are still there
my/test> goodbye
#<procedure quit args>
Regards,
Jost