From: Alessio S. <ale...@gm...> - 2009-05-18 08:13:23
|
On Mon, May 18, 2009 at 9:12 AM, Alessio Stalla <ale...@gm...> wrote: > On Mon, May 18, 2009 at 7:15 AM, Peter Tsenter <pts...@ho...> wrote: >> Statement >> >> ((Invocable) lispEngine).invokeFunction("hello", "world"); >> >> invokes abcl interactive debugger with a message >> >> >> Debugger invoked on condition of type UNBOUND-VARIABLE: >> The variable ABCL-SCRIPT-USER::SOMEVARIABLE is unbound. >> >> I don't rememeber how far back it used to work. > > Thanks for the report, I'll investigate it this evening. I haven't run > the example in a while, and even if I have some simple unit tests to > check the AbclScriptEngine, these tests are far from complete and the > example might do something which is not covered by them. > I've given a quick look at the AbclScriptEngine on Trac (I don't have my local working copy available now) and I've understood the problem. With my last commit I changed how the Lisp code is executed in a JSR-223 context. Before it went like this: The code string was parsed with read-from-string (with *package* bound to :abcl-script-user), the resulting Lisp code was enclosed in a (let ...) form with all the bindings passed through the ScriptContext, and finally eval'ed. This worked fine with snippets of code like those in the example and in my unit tests, but hadn't the correct behavior when loading a Lisp file, since the built-in load function behaves differently - it reads and evaluates a form at a time, so that e.g. in-package forms are allowed to change the current package and affect the reading of subsequent forms. So now I changed it to use a modified version of load that returns the value of the last form loaded. This solves the problem above. However, the let-form trick for establishing a set of bindings does not work anymore, since load always runs in a null lexical environment. So I also made bindings declared with ScriptContext special, so they can be seen by load. However, I forgot to change how function invocation works - it should now re-establish bindings, since those are now special and thus are not resolved at function declaration time but at function call time. It's not a hard thing to do, I should be able to fix it before tomorrow. Bye, Alessio |