This is the mail archive of the kawa@sources.redhat.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]
Other format: [Raw text]

Re: trouble handling exceptions


Hurst, Dave wrote:
I assume you are refering to the "if" statement in the loadSource() method
in kawa/standard/load.java.  In the version I have, it appears at line 160.

Linbe 154 in the CVS version.


I was able to try this work-around today.  Unfortunately, the change causes
other errors when I load .scm files into the environment.  Specifically, I'm
getting an "Unbound symbol new" exception:

Caused by: gnu.mapping.UnboundSymbol: Unbound symbol new
        at gnu.expr.Interpreter.getDefaultSymbolValue(Interpreter.java:638)
        at gnu.expr.Interpreter.getSymbolValue(Interpreter.java:645)
        at atFileLevel.apply(c:/Documents and Settings/hurst/My
Documents/build/scm/src/topology.scm:42)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:258)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:188)
        at kawa.standard.load.loadSource(load.java:176)
        at kawa.standard.load.loadSource(load.java:131)

The file topology.scm contains a number of definitions like the following:
(define-namespace NetworkInterface "class:com.lisletech.NetworkInterface")
(define nif-new NetworkInterface:new)

So I suspect the unbound symbol is coming from one of these definitions, but
I don't understand why the interpreter should think that the "new" method is
undefined.  It worked just fine before I made the change to load.java.

No immediate idea. But note that changing loadSource causes everything
in the file to be parsed/expanded before anything else, which can change things.


An alternativ solution may be to change the run routine in Shell so it doesn't print anything unless 'interactive'. However, the tricky part is when a while is loaded using a command-line flag. Nothing terribly
difficult, I think.


In any event, it doesn't look like I'll be able to use this change to
load.java to solve my problem with catching exceptions in my Java code that
were thrown from the Scheme code.  I'm investigating another approach in
which the .scm file contains only definitions and doesn't actually execute
anything and then the function that might throw an exception is called
directly from Java using eval().  This works, but it is a little bit awkward
for what I want to do.  I'd really like to be able to execute the same code
either loaded interactively or called from Java.  Any suggestions for other
approaches would be appreciated.

Well, generally "load" and "eval" are to be avoided. They defer all processing until run-time. Kawa is a compiler, and it is best to make
advantage of that. I.e. modules, separate compilation, compile-time
type-checking, better performance, better Java integration.
--
--Per Bothner
per@bothner.com http://per.bothner.com/



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