Re: Inferior processes and access to foreign libraries

2011-03-25 Thread meingbg
I believe FFI or Foreign function interface is a term previously used for
this, at least in the lisp world.
http://en.wikipedia.org/wiki/Foreign_function_interface

http://en.wikipedia.org/wiki/Foreign_function_interface/meingbg

On Thu, Mar 24, 2011 at 4:21 PM, Alexander Burger a...@software-lab.dewrote:

 Hi Jon,

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

 Good idea!

 I'm still not sure, however, if it is complete. I'm getting a bit
 confused about that, it is the only place where pil32 and pil64 are
 substantially different.

 What might be a proper title? Foreign Code Integration?

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



Inferior processes and access to foreign libraries

2011-03-24 Thread Thorsten
Hello,
one thing I like very much about emacs is the ability to run foreign
programs (like R and picolisp) as inferior process and communicate with them
as if they were part of emacs.

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?

Emacs obviously can use foreign programs, like ie ledger mode (
http://www.emacswiki.org/emacs/LedgerMode) which uses a fast program written
in C++.  I wonder if picolisp can access libraries written in other
languages too?

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

Can't picolisp do this too? Call Java (and C, C++, Python ...) functions
(with a list of data, maybe) and use the return value? Maybe using clojure
as man in the middle between java and picolisp who takes care of converting
lists in other datastructures and vice versa?

Thanks any help on the road to picolisp enlightment
Thorsten


Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Alexander Burger
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


Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Jon Kleiser

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


Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Alexander Burger
Hi Jon,

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

Good idea!

I'm still not sure, however, if it is complete. I'm getting a bit
confused about that, it is the only place where pil32 and pil64 are
substantially different.

What might be a proper title? Foreign Code Integration?

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


Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Jon Kleiser

Hi Alex,

On 24-03-11 16:21 , Alexander Burger wrote:

Hi Jon,


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

Good idea!

I'm still not sure, however, if it is complete. I'm getting a bit
confused about that, it is the only place where pil32 and pil64 are
substantially different.


If it's not complete, you can always add more later ... ;-)

What might be a proper title? Foreign Code Integration?

Cheers,
- Alex

I think Foreign Code Integration sounds good.

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


Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Thorsten
Hi Alexander,
thanks for all that information, definitely worth a wiki entry.
Due to limited skills number 1.  and number 4./5. seem to be the most
realistic options for me, but I will need some time to digest so much new
info.
My plans are to read and learn more about picolisp the next weeks, while
terminating some other stuff, and then build a small but real webapp in
picolisp - I'm already  looking forward for that.
Picolisp seems so easy and so powerful at the same time.
Cheers
Thorsten

2011/3/24 Alexander Burger a...@software-lab.de

 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



Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Thorsten
Hi Henrik,
that's what I thought - moving lists back and forth between two variants of
lisp should somehow be manageable.
Thanks for the tip, I wil have a closer look.
Thorsten

BTW a lot of nice articles on your blog.

2011/3/24 Henrik Sarvell hsarv...@gmail.com

 Hi Again :)

 Yes I've done some experimenting in this direction here:
 http://www.prodevtips.com/2010/05/30/clojure-with-a-picolisp-database-via-clojure-http-client/



 On Thu, Mar 24, 2011 at 7:03 PM, Thorsten 
 gruenderteam.ber...@googlemail.com wrote:

 Hello,
 one thing I like very much about emacs is the ability to run foreign
 programs (like R and picolisp) as inferior process and communicate with them
 as if they were part of emacs.

 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?

 Emacs obviously can use foreign programs, like ie ledger mode (
 http://wwwemacswiki.org/emacs/LedgerModehttp://www.emacswiki.org/emacs/LedgerMode)
 which uses a fast program written in C++.  I wonder if picolisp can access
 libraries written in other languages too?


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

 Can't picolisp do this too? Call Java (and C, C++, Python ...) functions
 (with a list of data, maybe) and use the return value? Maybe using clojure
 as man in the middle between java and picolisp who takes care of converting
 lists in other datastructures and vice versa?

 Thanks any help on the road to picolisp enlightment
 Thorsten





Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Thorsten
Hi Alexander,


Yeah, these are the easiest. If you have a 64-bit system, however, 3 is
 as simple as 1.


Unfortunately  I installed 32-bit Ubuntu on my machine, only to find out
later that it has 64-bit architecture ...

If you like, you might join the #picolisp IRC channel. Gives more
 interactive feedback. And, it looks we are in the same time zone :)



yes, I live in Berlin.  The #picolisp IRC channel is another thing I have to
check out (I never used IRC ;). But I already found an emacs mode for IRC,
so lets see ...

Cheers
Thorsten


Re: Inferior processes and access to foreign libraries

2011-03-24 Thread Terry Palfrey
On Thu, Mar 24, 2011 at 9:54 AM, Alexander Burger a...@software-lab.dewrote:

Hi Thorsten,


 If you like, you might join the #picolisp IRC channel. Gives more
 interactive feedback. And, it looks we are in the same time zone :)

 irc.freenode.net /join #picolisp

I highly recommend it Thorsten.