Can I extend lisp in C ++?

Is it possible to call a function from lisp from a library written in c or C ++? How can I extend lisp? This is useful when you want to make some system calls or such things.

+5
c ++ extend lisp
Dec 18 '08 at 20:26
source share
3 answers

It is unusual to call non lisp code from lisp and is rarely required. CLX (the X11 client implementation for CL) does not refer to the Xlib implementation, but "speaks" X11 directly. On any system, your CL implementation probably already has excellent operating system hosts, which makes this unnecessary.

However, the answer depends on the implementation of lisp:

In ECL, you can place the CL environment under C and just call cl_eval() with the code to execute. This may allow you to write the application (or the host of the application) in C (or C ++) and β€œcall” the lisp code.

There is a C-compatible calling interface in CCL that allows you to do something like this:

 (with-cstrs ((x "Hello World")) (#_puts x)) 

In most other CL implementations (like SBCL, and yes, this also works in ECL and CCL), you can use UFFI (or CFFI), which simply allows you to call C functions, which other people are talking about. If that's all you want to do, CFFI is a good, safe place to start.

+8
Dec 19 '08 at 2:34 a.m.
source share
β€” -
+5
Dec 18 '08 at 20:29
source share
+4
Dec 19 '08 at 1:26
source share



All Articles