Hi Alex,

This overview of the different ways of integration with other software is very good! It deserves a place in the wiki. ;-)

/Jon

On 24-03-11 15:08 , Alexander Burger wrote:
Hi Thorsten,

I wonder if one could build a picolisp app that fully integrates with R
(statistics software, http://www.r-project.org/) and GRASS GIS (a command
line GIS that uses a superset of shell commands, http://grass.fbk.eu/) on
its linux host machine?
There are basically five ways a PicoLisp program can be integrated with
other software:

1. Call existing library functions

    This is available only in the 64-bit version with the 'native'
    function. C functions can be directly called from Lisp code. For an
    extensive example, look at "lib/openGl.l".

2. Write a shared object file (DLL)

    This is analog in the 32-bit and 64-bit versions, but due to the
    underlying implementation such shared object files are written in C
    for the 32-bit version, and in assembly for the 64-bit version.
    Examples are the 'ext' and 'ht' libraries, built in the Makefile's
    ("src/ext.c", "src/ht.c", "src64/ext.l" and "src64/ht.l").

3. Write inline C code

    The 32-bit and 64-bit versions of PicoLisp behave a little different
    here. In the 32-bit version, these functions must contain glue code
    to convert between C and Lisp data. The file "misc/crc.l" contains an
    example for both versions.

4. Start other programs as sub-processes, and communicate with their
    standard I/O via pipes. This can be done with the 'in', 'out' and
    'pipe' functions.

5. Use sockets or some other type of IPC (e.g. named pipes) to
    communicate with another program.

Did I forget some other way?


It's always claimed that clojure is great because it has access to countless
java libraries on the jvm. But clojure is all about functional programming,
BTW, there is also ErsatzLisp, a subset of PicoLisp written in Java. It
provides for some ways to call the underlying JVM.


concurrency and avoiding mutable state, while java is all about objects with
mutable state. So it would only make sense for a clojure program to call
java libraries like pure functions without side effects and use the return
value, otherwise the clojure clean and scalable programming model would be
messed up.
Yep. The same problems apply to ErsatzLisp.


Can't picolisp do this too? Call Java (and C, C++, Python ...) functions
Several years ago, the PicoLisp GUI depended heavily on Java applets.
This stuff is still available as a separate tarball "picoJavaGUI.tgz".
It also contains a file "lib/java.l" which provides an interface to a
separately running JVM. This was never really used, though.

In one project we communicated with C++ programs via a PLIO library.
PLIO is the format used by PicoLisp internally for marshalling database
objects, for the 'pr' and 'rd' functions, and family IPC ('tell' etc.).
A skeleton for PLIO can be fetched from "software-lab.de/plio.tgz".

I'll gladly explain more details if you have specific questions :)

Cheers,
- Alex

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to