Greetings, currently I am building extension for AI, as indicated in title.
It works for Scheme (JScheme and Kawa). It is quite a simply one, for now,
I am only interested in evaluating simple symbolic expression, and then
build on that, adding other features etc.
However, I would also like to have access to Common Lisp, ergo ABCL.
Here is a code for its respective method:
@SimpleFunction(description = "ABCL evaluation")
public String ABCLEvaluation(String expression) {
// Environment.getInstance(true);
// Interpreter abclInterpreter = Interpreter.createInstance();
// Interpreter.createInstance();
// LispObject evalResult = Interpreter.evaluate(expression);
Interpreter interpreter = Interpreter.createInstance();
LispObject lo= interpreter.eval(expression);
return lo.getStringValue();
}
Commented code is there for completion sake, just as an indication that I
tried everything I could find in documentation and examples. Nothing works.
As you see, idea is a simple one, String is received, and then evaluated,
except that in the case of ABCL it isn't. For JScheme and Kawa logic is
precisely the same, environment/interpreter is initialized, expression is
evaluated and then it returns the correct result.
After playing with the various code combinations, there are always just two
errors present in logs, so here they are:
First one:
W/System.err(20761): java.lang.NullPointerException: Attempt to invoke
virtual method 'org.armedbear.lisp.LispObject
org.armedbear.lisp.Interpreter.eval(java.lang.String)' on a null object
reference
W/System.err(20761): at
lisp.tomislavt.ext.LispEvaluation.ABCLEvaluation(LispEvaluation.java:46)
W/System.err(20761): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(20761): at
java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(20761): at
gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
W/System.err(20761): at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(20761): at
gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
W/System.err(20761): at
gnu.mapping.MethodProc.applyN(MethodProc.java:113)
W/System.err(20761): at gnu.kawa.reflect.Invoke.applyN(Invoke.java:193)
W/System.err(20761): at
gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(20761): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(20761): at
gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(20761): at
com.google.youngandroid.runtime.callComponentMethod(runtime1661793284635134238.scm:879)
W/System.err(20761): at
appinventor.ai_test.AbclKawaTest.Screen1.Abcl$Click(Screen1.yail:68)
W/System.err(20761): at
appinventor.ai_test.AbclKawaTest.Screen1$frame.apply0(Screen1.yail:456)
W/System.err(20761): at gnu.expr.ModuleBody.applyN(ModuleBody.java:226)
W/System.err(20761): at
gnu.expr.ModuleMethod.applyN(ModuleMethod.java:216)
W/System.err(20761): at
gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(20761): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(20761): at
gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(20761): at
appinventor.ai_test.AbclKawaTest.Screen1.dispatchEvent(Screen1.yail:10121)
W/System.err(20761): at
com.google.appinventor.components.runtime.EventDispatcher.delegateDispatchEvent(EventDispatcher.java:220)
W/System.err(20761): at
com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent(EventDispatcher.java:198)
W/System.err(20761): at
com.google.appinventor.components.runtime.Button.Click(Button.java:51)
W/System.err(20761): at
com.google.appinventor.components.runtime.Button.click(Button.java:43)
W/System.err(20761): at
com.google.appinventor.components.runtime.ButtonBase.onClick(ButtonBase.java:656)
W/System.err(20761): at android.view.View.performClick(View.java:4848)
W/System.err(20761): at
android.view.View$PerformClick.run(View.java:20262)
W/System.err(20761): at
android.os.Handler.handleCallback(Handler.java:815)
W/System.err(20761): at
android.os.Handler.dispatchMessage(Handler.java:104)
W/System.err(20761): at android.os.Looper.loop(Looper.java:194)
W/System.err(20761): at
android.app.ActivityThread.main(ActivityThread.java:5631)
W/System.err(20761): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(20761): at
java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(20761): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
W/System.err(20761): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
I/RuntimeErrorAlert(20761): in alert
Second one:
W/System.err(26401): Unable to determine LISP_HOME.
W/System.err(26401): Unable to determine LISP_HOME.
W/System.err(26401): org.armedbear.lisp.IntegrityError
W/System.err(26401): at
org.armedbear.lisp.Primitives$pf_error.execute(Primitives.java:1577)
W/System.err(26401): at
org.armedbear.lisp.Primitive.execute(Primitive.java:113)
W/System.err(26401): at
org.armedbear.lisp.Symbol.execute(Symbol.java:803)
W/System.err(26401): at org.armedbear.lisp.Lisp.error(Lisp.java:383)
W/System.err(26401): at
org.armedbear.lisp.Load.loadSystemFile(Load.java:322)
W/System.err(26401): at
org.armedbear.lisp.Interpreter.initializeLisp(Interpreter.java:172)
W/System.err(26401): at
org.armedbear.lisp.Interpreter.createInstance(Interpreter.java:72)
W/System.err(26401): at
lisp.tomislavt.ext.LispEvaluation.ABCLEvaluation(LispEvaluation.java:48)
W/System.err(26401): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(26401): at
java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(26401): at
gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
W/System.err(26401): at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(26401): at
gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
W/System.err(26401): at
gnu.mapping.MethodProc.applyN(MethodProc.java:113)
W/System.err(26401): at gnu.kawa.reflect.Invoke.applyN(Invoke.java:193)
W/System.err(26401): at
gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(26401): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(26401): at
gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(26401): at
com.google.youngandroid.runtime.callComponentMethod(runtime284371300273757224.scm:879)
W/System.err(26401): at
appinventor.ai_test.AbclKawaTest3.Screen1.Abcl$Click(Screen1.yail:68)
W/System.err(26401): at
appinventor.ai_test.AbclKawaTest3.Screen1$frame.apply0(Screen1.yail:456)
W/System.err(26401): at gnu.expr.ModuleBody.applyN(ModuleBody.java:226)
W/System.err(26401): at
gnu.expr.ModuleMethod.applyN(ModuleMethod.java:216)
W/System.err(26401): at
gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(26401): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(26401): at
gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(26401): at
appinventor.ai_test.AbclKawaTest3.Screen1.dispatchEvent(Screen1.yail:10121)
W/System.err(26401): at
com.google.appinventor.components.runtime.EventDispatcher.delegateDispatchEvent(EventDispatcher.java:220)
W/System.err(26401): at
com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent(EventDispatcher.java:198)
W/System.err(26401): at
com.google.appinventor.components.runtime.Button.Click(Button.java:51)
W/System.err(26401): at
com.google.appinventor.components.runtime.Button.click(Button.java:43)
W/System.err(26401): at
com.google.appinventor.components.runtime.ButtonBase.onClick(ButtonBase.java:656)
W/System.err(26401): at android.view.View.performClick(View.java:4848)
W/System.err(26401): at
android.view.View$PerformClick.run(View.java:20262)
W/System.err(26401): at
android.os.Handler.handleCallback(Handler.java:815)
W/System.err(26401): at
android.os.Handler.dispatchMessage(Handler.java:104)
W/System.err(26401): at android.os.Looper.loop(Looper.java:194)
W/System.err(26401): at
android.app.ActivityThread.main(ActivityThread.java:5631)
W/System.err(26401): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(26401): at
java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(26401): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
W/System.err(26401): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
I/System.out(26401): ERROR placeholder called with arguments:
I/System.out(26401): Failed to find loadable system file 'boot.lisp' in
boot classpath.
I/System.out(26401): Failed to find loadable system file 'boot.lisp' in
boot classpath.
W/System.err(26401): org.armedbear.lisp.IntegrityError
W/System.err(26401): at
org.armedbear.lisp.Primitives$pf_error.execute(Primitives.java:1577)
W/System.err(26401): at
org.armedbear.lisp.Primitive.execute(Primitive.java:113)
W/System.err(26401): at
org.armedbear.lisp.Symbol.execute(Symbol.java:803)
W/System.err(26401): at org.armedbear.lisp.Lisp.error(Lisp.java:383)
W/System.err(26401): at
org.armedbear.lisp.Load.loadSystemFile(Load.java:322)
W/System.err(26401): at
org.armedbear.lisp.Interpreter.initializeLisp(Interpreter.java:172)
W/System.err(26401): at
org.armedbear.lisp.Interpreter.createInstance(Interpreter.java:72)
W/System.err(26401): at
lisp.tomislavt.ext.LispEvaluation.ABCLEvaluation(LispEvaluation.java:48)
W/System.err(26401): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(26401): at
java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(26401): at
gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
W/System.err(26401): at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(26401): at
gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
W/System.err(26401): at
gnu.mapping.MethodProc.applyN(MethodProc.java:113)
W/System.err(26401): at gnu.kawa.reflect.Invoke.applyN(Invoke.java:193)
W/System.err(26401): at
gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(26401): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(26401): at
gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(26401): at
com.google.youngandroid.runtime.callComponentMethod(runtime284371300273757224.scm:879)
W/System.err(26401): at
appinventor.ai_test.AbclKawaTest3.Screen1.Abcl$Click(Screen1.yail:68)
W/System.err(26401): at
appinventor.ai_test.AbclKawaTest3.Screen1$frame.apply0(Screen1.yail:456)
W/System.err(26401): at gnu.expr.ModuleBody.applyN(ModuleBody.java:226)
W/System.err(26401): at
gnu.expr.ModuleMethod.applyN(ModuleMethod.java:216)
W/System.err(26401): at
gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(26401): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(26401): at
gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(26401): at
appinventor.ai_test.AbclKawaTest3.Screen1.dispatchEvent(Screen1.yail:10121)
W/System.err(26401): at
com.google.appinventor.components.runtime.EventDispatcher.delegateDispatchEvent(EventDispatcher.java:220)
W/System.err(26401): at
com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent(EventDispatcher.java:198)
W/System.err(26401): at
com.google.appinventor.components.runtime.Button.Click(Button.java:51)
W/System.err(26401): at
com.google.appinventor.components.runtime.Button.click(Button.java:43)
W/System.err(26401): at
com.google.appinventor.components.runtime.ButtonBase.onClick(ButtonBase.java:656)
W/System.err(26401): at android.view.View.performClick(View.java:4848)
W/System.err(26401): at
android.view.View$PerformClick.run(View.java:20262)
W/System.err(26401): at
android.os.Handler.handleCallback(Handler.java:815)
W/System.err(26401): at
android.os.Handler.dispatchMessage(Handler.java:104)
W/System.err(26401): at android.os.Looper.loop(Looper.java:194)
W/System.err(26401): at
android.app.ActivityThread.main(ActivityThread.java:5631)
W/System.err(26401): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(26401): at
java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(26401): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
W/System.err(26401): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
I hope that I am missing something obvious :), and I am thankful in advance
for any input, advice or idea.
Some additional clarification may be in order, MIT App Inventor is
environment for rapid development of applications for Android (Arduino,
Lego mindstorm etc.), hence it doesn't follow usual Android work-flow.
Backbone of it is Kawa, components, extensions are written in Java, but
more about it can be easily find on its webpage.
First log example is fairly useless one imo, when i tested my extension
with simple App, same expression was evaluated correctly in both Kawa and
JScheme, so that String was not a null one, but I've put it here for
completion sake.
For the second one I've find something similar for version a.1 or 1.2, back
in 2012, I believe, and it was something about dynamic linking during the
build process.
I am using ABCL 1.5 jar that I downloaded from the ABCL project page.
In any case, I am bit at loss, and thus, I would appreciate any advice what
should I try next. Thank you for your time.
Respectfully,
Tomislav Tomsic