Subject: [clisp-list] Question

From: [email-masked]
Date: Wed Oct 15 22:08:04 2003

Hello,

First off, I would like to say that I very much enjoy CLisp. Because of the nature of Lisp, it is hard to find a lot of resources on it, so I truly enjoy having something like CLisp for free!

My question is based off of a need that I have. As a developer I am in the need of creating part of my project in C++, and would _LOVE_ to create some parts of it in Lisp. Being able to do such a thing would greatly ease the development process. I was wondering, is it possible for me to be able to compile Lisp code into something like object code, and then use G++ to link my C++ code and the object code that was generated from the Lisp? I guess, basicly, what I am needing to do is be able to call Lisp functions from C++ functions.

Thanks!

Jason Whitehorn

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Wed Oct 15 22:41:02 2003

[email-masked] writes:
> Hello,
> 
> First off, I would like to say that I very much enjoy CLisp. Because
> of the nature of Lisp, it is hard to find a lot of resources on it,
> so I truly enjoy having something like CLisp for free!
> 
> My question is based off of a need that I have. As a developer I am
> in the need of creating part of my project in C++, and would _LOVE_
> to create some parts of it in Lisp. Being able to do such a thing
> would greatly ease the development process. I was wondering, is it
> possible for me to be able to compile Lisp code into something like
> object code, and then use G++ to link my C++ code and the object
> code that was generated from the Lisp? I guess, basicly, what I am
> needing to do is be able to call Lisp functions from C++ functions.

You could do that with gcl or ecl:

http://ecls.sf.net/
http://savannah.gnu.org/projects/gcl

-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
Do not adjust your mind, there is a fault in reality.

---

From: "John K. Hinsdale" <[email-masked]>
Date: Thu Oct 16 04:27:18 2003

> I am in the need of creating part of my project in C++, and would
 > _LOVE_ to create some parts of it in Lisp.

 > is it possible for me to be able to compile Lisp code into
 > something like object code, and then use G++ to link my C++ code and
 > the object code that was generated from the Lisp?

No, CLISP does not compile into native machine code; it uses something
like a byte-code interpreter similar to perl or Java (w/out JIT).

 > I guess, basicly, what I am needing to do is be able to call Lisp
 > functions from C++ functions.

However you can still call C/C++ functions from Lisp and call Lisp
functions from C/C++ using CLISP's Foreign Function Interface (FFI)

   http://clisp.cons.org/impnotes/dffi.html

If linking w/ C++ you'll need to make sure C++ unerstands the external
functions are C and not C++ (i.e., use the 'extern "C" {}' directive)
and also make sure you link in the library which provides the CLISP
runtime environment (lisp.a).