This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Making 'require' bind functions in an environment.
- To: kawa at sourceware dot cygnus dot com
- Subject: Making 'require' bind functions in an environment.
- From: Jocelyn Paine <popx at pop3 dot ifs dot org dot uk>
- Date: Wed, 5 Sep 2001 19:30:20 +0100 (GMT)
I'm generating lambda expressions and evaluating them into functions
dynamically, and trying to sort out some problems with getting things
bound in environments. My immediate puzzle is the behaviour of eval and
require:
(define (test)
(let ( (E (interaction-environment))
)
(eval `(require <MyModule>) E)
(format #t "Bound ~A~%" (environment-bound? E 'MyFn))
)
)
Here, test is defined in a static module. It requires another one,
MyModule, which defines MyFn. I thought the
(eval `(require <MyModule>) E)
should bind MyFn in E, but it doesn't - environment-bound returns false.
What I'm actually doing is to implement a BRL-like system for compiling
dynamic Web pages into functions. MyModule defines the compilation
functions, of which MyFn is the main one. This reads a page, converts it
to a lambda-expression, and eval's that to make it into a function.
The Web page may contain references to sub-pages that are to be included
in it. MyFn implements these by replacing them by internal calls to MyFn
in the lambda-expression it is constructing. My problem is that I haven't
managed to evaluate this lambda-expression in such a way that these
internal calls to MyFn are bound. Schematically, MyFn generates a
lambda-expression
(lambda (args) ..... (MyFn args1) ... (MyFn args2) ... ...)
which must then be evaluated and applied, in an environment such that the
inner calls to MyFn work.
If I don't compile 'test' above before calling it, everything works fine.
Jocelyn Paine
http://www.ifs.org.uk/~popx/
+44 (0)7768 534 091