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


Per Bothner wrote:
> 
> So the problem is figuring out what is "top level".  Just checking
> if the input file is "interactive" doesn't work, since we might have
> a top-level laod from a file.
> 
> My preferred fix is to change
>     if (true)
> in the line 154 of kawa/standard/load.java by
>     if (false)
> This is what I plan on doing anyway - for oen thing it make compiled
> and immediate files more simpler.  I've been leary of it, because it
> does break soem things, such as defining a "procedural" macro (i.e.
> non-syntax-rules) and using it in the same file.
> 
> At least as a work-around, I suggest making this change.

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.
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.

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.

--DaveH		"Be Excellent to each other!"


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