|
From: Timothy H. <tim...@ma...> - 2002-06-18 16:52:33
|
On Tuesday, June 18, 2002, at 10:03 AM, tleek wrote:
>
> Hi,
>
> I'm using JScheme from java but having some difficulties. Is there
> javadoc out there?
I've created a javadoc for jscheme:
http://www.cs.brandeis.edu/~tim/jscheme/doc/javadoc/
> I don't even know, e.g., if
>
> foo = JS.eval(schemeCommand);
>
> throw an exception that needs catching.
Jscheme wraps all of its exceptions as subclasses of RuntimeException
so you are not forced to catch them.
It is a good idea to have the Scheme code catch the exception:
try
foo= JS.eval("(tryCatch ..SchemeCode.. (lambda(e) e))");
catch(Exception e) { .... };
If the exception is thrown inside SchemeCode during a reflection call to
Java,
then the tryCatch will
For example, here is a test program which wraps Scheme expressions in
a tryCatch:
> import jscheme.JS;
>
> public class Test {
> public static void main (String[] args) {
> Object foo = JS.eval("(tryCatch "+ args[0] + "(lambda(e) e))");
> System.out.println("foo= "+foo);
> System.out.println("foo class is "+foo.getClass());
> }
> }
>
and here are some examples of its use:
> % java -cp lib/jscheme.jar:. Test "(java.io.Socket. {129.64.3.193}
> 14232)"
> Javadot WARNING: Can't find classjava.io.Socket
> foo= SchemeException:[[ERROR: undefined variable "java.io.Socket."]]
> foo class is class jscheme.SchemeException
>
A Scheme error (e.g. making a mistake in the javadot notation, will
return as
a SchemeException object. This kind of error can be caught during
debugging
hopefully.
> % java -cp lib/jscheme.jar:. Test "(java.net.Socket. {129.64.3.193}
> 14232)"
> foo= java.net.ConnectException: Connection refused
> foo class is class java.net.ConnectException
Otherwise, if the error is thrown by a Java method or constructor, then
the
error itself will be returned and one can test for the type of error.
Here we tried
to open a Socket unsuccessfully.
>
>
> % java -cp lib/jscheme.jar:. Test "(/ 1 0)"
> foo= java.lang.ArithmeticException: / by zero
> foo class is class java.lang.ArithmeticException
>
Here we divide by zero and get an ArithmeticException
>
> Help!
Does this help?
>
> p.s. Can you respond to this email address with any assistance. I'm not
> on these lists.
>
> --
>
> ================================================
> Tim Leek, S1-480
> BMD Systems and Analysis
>
> __o MIT Lincoln Laboratory
> _ \<,_ 244 Wood Street
> (_)/ (_) Lexington, MA 02420-9108
>
> email: tl...@ll...
> phone: (781) 981-2975
>
> Machine Learning Reading Group
> http://rezrov (Lab internal)
> ================================================
>
>
>
>
> ----------------------------------------------------------------------------
> Bringing you mounds of caffeinated joy
>>>> http://thinkgeek.com/sf <<<
>
> _______________________________________________
> Jscheme-user mailing list
> Jsc...@li...
> https://lists.sourceforge.net/lists/listinfo/jscheme-user
>
|