This is the mail archive of the kawa@sourceware.cygnus.com mailing list for the Kawa project.


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

Re: cannot 'require' in embedded code (AGAIN...)


Marco Vezzoli <marco.vezzoli@st.com> writes:

> I'm desperately trying to upload a compiled module inside an interpreter
> embedded in my java code.
> It seems that evalunating a "require" statement is the correct way,

Well, not really.

The thing to remember is that require is a *declaration*.
Furthermore, require creates *local* bindings, that are
not re-exported.  I think the correct implementation
when evaluating a declaration (including require) is to
add the declared bindings to the eval's environment,
so (to the extent things are working as intended) what
you are doing should work.  But I still think that in
the idea of eval'ing a require statement is unlikely
to be right thing.  The point of require is that it is
part of a module system - which to me means compile-time
knowledge and control of exported/imported bindings.
Eval is about the opposite - no compile-time control.

In general, people overuse eval.  The only really good
reason to use eval is when you need to evaluate a Scheme
expression *provided by a human at run-time*.  There are
sometimes other good reasons to use eval - but most of
the time you shouldn't use it.

Note that you do have the option of calling load on a
compiled module.  That may make more sense.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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