Re: Newb question about calling Scheme from Java
"Mike J. Bell" <[email protected]> Wed, 3 Sep 2008 08:29:19 -0400
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
--===============0309065105== Content-Type: multipart/alternative; boundary="----=_Part_24056_3689235.1220444959824" ------=_Part_24056_3689235.1220444959824 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Turns out the context I was looking for is *toplevel* instead of r5rs. (Don't know where I got that in my head). And passing this is as simple as Value value = Util.javaWrap(this); Works now, thanks! On Tue, Sep 2, 2008 at 3:15 PM, Mike J. Bell <[email protected]> wrote: > I'm trying to integrate SISC as a Scheme interpreter into a larger, > established product written in Java. Anybody else do this, open-source > like, so I might peek at the ways and means? Any advice on trying to > "replicate" a Java "programmer's" API inside SISC? (i.e., ways to automate > all the (->jstring ...) and wrap/unwrap code that must go on with s2j). > > But I have specific questions to start out. I need to pass a handle from > the "public" part of the Java API into the SISC interpreter so that I might > start tinkering. (It's like a Java "environment"). I find my heap, and do > something like: > > Context.execute(appContext, new SchemeCaller() { > public Object execute(Interpreter interpreter) throws SchemeException { > Symbol symbol = new Symbol("foobar"); > Value value = SchemeBoolean.TRUE; > Symbol context = new Symbol("r5rs"); > > interpreter.define(symbol, value, context); > interpreter.eval("...my scheme code..."); > ... > > The problem is that foobar isn't defined in my environment inside the eval > statement. I'm guessing that context=>Symbol("r5rs") is wrong here, but the > API docs don't really point me in a good direction. > > Can anybody help with this first bit; i.e., how can I pass things into my > Scheme environment properly? > > Thanks in advance for any simple and/or complex hints! > -- Mike J. Bell on gmail ------=_Part_24056_3689235.1220444959824 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline <div dir="ltr">Turns out the context I was looking for is *toplevel* instead of r5rs. (Don't know where I got that in my head).<br><br>And passing this is as simple as<br><br>Value value = Util.javaWrap(this);<br><br> Works now, thanks!<br><br><br><br><div class="gmail_quote">On Tue, Sep 2, 2008 at 3:15 PM, Mike J. Bell <span dir="ltr"><<a href="mailto:[email protected]">[email protected]</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div dir="ltr">I'm trying to integrate SISC as a Scheme interpreter into a larger, established product written in Java. Anybody else do this, open-source like, so I might peek at the ways and means? Any advice on trying to "replicate" a Java "programmer's" API inside SISC? (i.e., ways to automate all the (->jstring ...) and wrap/unwrap code that must go on with s2j).<br> <br>But I have specific questions to start out. I need to pass a handle from the "public" part of the Java API into the SISC interpreter so that I might start tinkering. (It's like a Java "environment"). I find my heap, and do something like:<br> <br>Context.execute(appContext, new SchemeCaller() {<br> public Object execute(Interpreter interpreter) throws SchemeException {<br> Symbol symbol = new Symbol("foobar");<br> Value value = SchemeBoolean.TRUE;<br> Symbol context = new Symbol("r5rs");<br><br> interpreter.define(symbol, value, context);<br> interpreter.eval("...my scheme code...");<br>...<br><br>The problem is that foobar isn't defined in my environment inside the eval statement. I'm guessing that context=>Symbol("r5rs") is wrong here, but the API docs don't really point me in a good direction.<br> <br>Can anybody help with this first bit; i.e., how can I pass things into my Scheme environment properly?<br><br>Thanks in advance for any simple and/or complex hints!<br></div></blockquote></div><br clear="all"><br>-- <br> Mike J. Bell on gmail<br> </div> ------=_Part_24056_3689235.1220444959824-- --===============0309065105== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ --===============0309065105== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Sisc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sisc-users --===============0309065105==--