On Thu, May 27, 2010 at 11:45:57AM +0200, Henrik Sarvell wrote: > Now pretend I have a PL database that listens on say port 4040, could > it be possible to use the current Java interop code to pass data to > that database for storage?
This is not directly supported by the existing interfaces, as 'Reflector' is itself a server which expects to be queried by PicoLisp. On the PicoLisp side nothing special needs to be implemented. On the Java side you need library that connects to the PicoLisp server, sends requests, and receives answers via "java/InOut.java". This is in fact very similar to what the old Java GUI applets are doing (mainly in "java/Pico.java"). These applets connect back to the HTML server on a dedicated port (passed via the HTML page as a parameter to the applet), and use the PLIO functions (in "java/InOut.java") to send events and receive layout and content informations from the server. Parts of the 'connect' method (line 36 in "java/Pico.java") and all the calls to 'IO.somefunction()' might be useful. You could simply send complete PicoLisp statements, packed into Java arrays. They will appear as lists in PicoLisp. But easier is probably sending the data items individually, as you then have better control over the type. For example, with 'prSym()' you can then send internal symbols (typically functions), directly executable on the PicoLisp side (I hope to don't forget about security ;-) For example, to call (collect 'nm '+Cls) on the DB server (not tested): IO.Out.write(BEG); IO.prSym("collect"); IO.Out.write(BEG); IO.prSym("quote"); IO.Out.write(DOT); IO.prSym("nm"); IO.Out.write(BEG); IO.prSym("quote"); IO.Out.write(DOT); IO.prSym("+Cls"); Out.write(END); IO.flush(); So this is a bit tedious. If the PicoLisp server uses a dedicated port for the Java queries, and does not (while (rd) (eval @) ) but instead (while (rd) (apply @ (rd)) ) then you can send the arguments without quoting in a list (array): Object args; // fill args with 'nm' and '+Cls', and possibly more IO.prSym("collect"); IO.print(args); IO.flush(); Hope this works ;-) Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe