This is the mail archive of the guile@sourceware.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]

Re: Safe Guile?



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

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