* environments and eval with user-defined library
@ 2017-02-18 16:36 Peter Lane
2017-02-24 7:48 ` Per Bothner
0 siblings, 1 reply; 2+ messages in thread
From: Peter Lane @ 2017-02-18 16:36 UTC (permalink / raw)
To: kawa
I've been using eval and environment as follows:
#|kawa:1|# (define env (environment '(srfi 1)))
#|kawa:2|# (environment-bound? env 'iota)
#t
#|kawa:3|# (eval '(iota 10) env)
(0 1 2 3 4 5 6 7 8 9)
Although this works for builtin libraries (like srfi 1), this does not
appear to work for my own libraries, e.g. below. Notice on line two,
the symbol is bound in the environment, so (lib test) seems to be found
and loaded into 'env'. But during 'eval' there is no lib.test class found.
I'm running Kawa in r7rs mode, with the library in "./lib/test.sld":
$ kawa --r7rs -Dkawa.import.path="./*.sld"
Is this a limitation in the implementation? Or do I need to give kawa
some more information?
#|kawa:1|# (define env (environment '(lib test)))
#|kawa:2|# (environment-bound? env 'test-me)
#t
#|kawa:3|# (eval '(test-me) env)
Exception in thread "main" java.lang.ExceptionInInitializerError
at atEvalLevel-1.run(stdin:3)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:293)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:212)
at kawa.lang.Eval.evalBody(Eval.java:100)
at kawa.lang.Eval.evalForm$X(Eval.java:27)
at kawa.lib.scheme.eval.eval$X(eval.scm:9)
at atInteractiveLevel-3.run(stdin:3)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:293)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:212)
at kawa.Shell.run(Shell.java:283)
at kawa.Shell.run(Shell.java:196)
at kawa.Shell.run(Shell.java:183)
at kawa.repl.processArgs(repl.java:714)
at kawa.repl.main(repl.java:820)
Caused by: java.lang.ClassNotFoundException: lib.test
at gnu.mapping.WrappedException.rethrow(WrappedException.java:121)
at gnu.expr.Compilation.setupLiterals(Compilation.java:2984)
at lib.test.<clinit>(test.sld)
... 14 more
Caused by: java.lang.ClassNotFoundException: lib.test
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at gnu.bytecode.ArrayClassLoader.loadClass(ArrayClassLoader.java:132)
at gnu.bytecode.ArrayClassLoader.loadClass(ArrayClassLoader.java:132)
at gnu.expr.Compilation.setupLiterals(Compilation.java:2965)
... 15 more
--
Peter Lane
http://peterlane.info
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: environments and eval with user-defined library
2017-02-18 16:36 environments and eval with user-defined library Peter Lane
@ 2017-02-24 7:48 ` Per Bothner
0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2017-02-24 7:48 UTC (permalink / raw)
To: Peter Lane, kawa
Sorry I almost forgot about this question.
On 02/18/2017 08:36 AM, Peter Lane wrote:
> I've been using eval and environment as follows:
>
> #|kawa:1|# (define env (environment '(srfi 1)))
> #|kawa:2|# (environment-bound? env 'iota)
> #t
> #|kawa:3|# (eval '(iota 10) env)
> (0 1 2 3 4 5 6 7 8 9)
>
> Although this works for builtin libraries (like srfi 1), this does not appear to work for my own libraries, e.g. below.
Could be a classpath issue. Could also be this just doesn't work for
libraries loaded from source a compile on-the-fly, That has
probably not been tested as much as one would like.
> Caused by: java.lang.ClassNotFoundException: lib.test
> at gnu.mapping.WrappedException.rethrow(WrappedException.java:121)
> at gnu.expr.Compilation.setupLiterals(Compilation.java:2984)
> at lib.test.<clinit>(test.sld)
> ... 14 more
Notice how the class lib.test is complaining that lib.test isn't found ...
Probably some ClassLoader not being set up right.
Possible a missing call to Compilation.usedClass.
If you can make a simple self-contained test-case I'll look into it.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-24 7:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-18 16:36 environments and eval with user-defined library Peter Lane
2017-02-24 7:48 ` Per Bothner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).