modules and sisc-initial-environment

Norman Gray <[email protected]> Thu, 1 Feb 2007 11:50:58 +0000
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
Greetings.

I'm puzzled at the relationship between sisc-initial-environment and  
modules.  I thought the following would work, but it doesn't, and I  
wonder what I'm misunderstanding.

I create a module

     (module m
         (mval)
       (define mval 1))

and adjust my CLASSPATH so that sisc (CVS head) can find m.scm.  The  
following then works:

     (require-library 'm)
     (import m)
     (display mval)
     (newline)

This displays '1', as it should.  The following, however, does not work:

(define (eval-list el)
   (let ((env (sisc-initial-environment)))
     (let loop ((l el))
       (or (null? l)
           (let ()
             (eval (car l) env)
             (loop (cdr l)))))))
(eval-list '((require-library 'm)
              (import m)
              (display mval)
              (newline)))

This produces the error `import from unknown module m'.  If I change  
sisc-initial-environment to interaction-environment then this does  
work, but the mval binding is then visible at the top level.

Chapter 3 remarks that sisc-initial-environment creates `a distinct  
environment which contains only the bindings initially available when  
SISC starts', which I took to include module handling, not least  
because the remark `The top-level environment itself is merely a  
special cased symbolic environment.' seems to suggest that anything  
you can do at the top level, you can also do within a symbolic  
environment.

I can't find anything in Chapter 10 which I recognise as forbidding  
what I'm trying to do here unless, in `[t]he import form imports  
bindings from a named module [...] into the current lexical scope',  
the word `lexical' is intended to imply that this really is a  
_lexical_ matter, rather than one of manipulating environments.

The referenced section of the Chez Scheme manual says that `Bindings  
exported from a named module may be made visible via an import form  
wherever the module's name is visible.'  I'm not _completely_ sure  
what `visible' means here, though interestingly, (display m) behaves  
differently in the two cases above, producing the error "invalid  
syntax m" in the first case, and "undefined variable 'm'" in the  
second. (of course it ought to fail, but I would have thought it  
would do so in the same way in both cases).

I'm a bit stuck: can anyone shed light?

Thanks for pointers,

Norman


-- 
------------------------------------------------------------------------ 
----
Norman Gray  /  http://nxg.me.uk
eurovotech.org  /  University of Leicester, UK




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642