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]

Re: Where should guile modules store meta data?


Clark McGrew <mcgrew@ale.physics.sunysb.edu> writes:

> about simple syntax for a
> simple users (me).  


What about the following module interface:

(module-create <module name>)        create a new module
(module-go <module name>)            go to a (previously created) module
(module-open (<module-name> ...))    import modules
(module-access ((<module-name> ...)) access (pre-load) modules
(module-export (signature))          export variables

That's all.


An example:

bash$ ls ice-9/*.scm
ice-9/boot-9.scm   ice-9/test1.scm    ice-9/test3.scm
ice-9/debug.scm    ice-9/test2.scm    ice-9/version.scm

bash$ ./libguile/guile
ice-9/root> (module-create (ice-9 test1))
ERROR: module exists but has not been loaded
ABORT: (misc-error)
ice-9/root> (module-ref (ice-9 test1) a)
10
ice-9/root> ((module-ref (ice-9 test1) b)) ; defined as (b) (display (+ a 1)))
11
ice-9/root> (module-go (ice-9 test100))
ERROR: module could not be loaded ice-9/test100
ABORT: (misc-error)
ice-9/root> (module-create (ice-9 test100))
ice-9/root> (module-go (ice-9 test100))
ice-9/test100> a
ERROR: Unbound variable: a
ABORT: (misc-error)
ice-9/test100> (module-open ((ice-9 test1) (ice-9 root))); open test1 and root
ice-9/test100> a                    ; from test1
10
ice-9/test100> (define a (+ a 500)) ; shadow binding from test1
ice-9/test100> a                    ; from test100
510
ice-9/test100> (b)                  ; memoized from test1
11
ice-9/test100> (define (b) (begin (display a) (display "\n")))
ice-9/test100> (b)                  ; the new binding
510
ice-9/test100> (undefine a)         ; un-shadow
ice-9/test100> (b)                  ; from test1
10
ice-9/test100> (module-go (ice-9 test 1))
ice-9/test1> (define a 5000)      
ice-9/test1> (module-ref (ice-9 test100) a)
5000
ice-9/test1> (0)
ice-9/test100> (0)
ice-9/root> bash$


I've put the code at 
  -> ftp://ftp.tfh-berlin.de/pub/incoming/guile-module-hack-080699.tar.gz


Jost

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