"willi" <wi...@willi.com> writes: > NO, you can only link c++ funktions to lisp not vice versa
AFAIK not even that. I think most languages support linking of C objects, not C++. The only way to link in the C++ is to go through a C layer, pretty much the way it is done in JNI.
Zachary Turner <ztur...@elsitech.com> wrote: >can LISP functions be linked to C/C++?
Um, what platform are we talking about? What Lisp implementation? What C or C++ implementation?
On my Macintosh, with Macintosh Common Lisp and Metrowerks Codewarrior, it's easy (provided you do not care about supporting old Macs.). You simply compile the C and C++ as a shared library, provide a pointer to the library, define a few entry points in Lisp, and you're off. It is necessary that the main program be in Lisp and the C or C++ in a shared library.
"willi" <wi...@willi.com> writes: > NO, you can only link c++ funktions to lisp not vice versa
> So long willi
> Zachary Turner schrieb in Nachricht <73c99f$nl...@uuneo.neosoft.com>... > >can LISP functions be linked to C/C++?
There is at least one implementation, where this is wrong: Eclipse Common Lisp compiles Common Lisp functions to C functions, which can be linked against other C/C++ code. Eclipse is a very reasonably priced commercial CL implementation available for Win32 and Linux, IIRC. Take a look at http://www.elwood.com/eclipse/ for more information.
IIRC there is also EcoLisp, which does similar things, but I don't know any details...
>Um, what platform are we talking about? What Lisp implementation? >What C or C++ implementation?
>On my Macintosh, with Macintosh Common Lisp and Metrowerks Codewarrior, >it's easy (provided you do not care about supporting old Macs.). >You simply compile the C and C++ as a shared library, provide a >pointer to the library, define a few entry points in Lisp, and >you're off. It is necessary that the main program be in Lisp >and the C or C++ in a shared library.
No No. l I want the other way around. I want to know if I can write code in LISP and link it into a program i've written in C or C++. It shouldn't matter what platform or implementation of anything I'm on, unless there are only certain LISP compilers that can do this. C functions have a standard calling convention. It's a matter of whether or not the LISP compiler can compile it to a C function. All it really has to do is put the underscore in front of a function name (of course i know nothing about LISP or how it handles functions. the whole reason i started the thread is because i want to know what i can and can't do with LISP, seeing as how i'm about to start getting heavily into AI programming.) But just to clarify i'm using Windows NT 4.0 and Visual Studio 6.0. So i want to write some functions in LISP, compile them into a .DLL (using Allegro CL 5.0 more than likely) and call one of these .DLL functions from my C++ program. Can this be done?
On Tue, 24 Nov 1998 12:45:12 -0000, Zachary Turner <ztur...@elsitech.com> wrote: >>Um, what platform are we talking about? What Lisp implementation? >>What C or C++ implementation?
>>On my Macintosh, with Macintosh Common Lisp and Metrowerks Codewarrior, >>it's easy (provided you do not care about supporting old Macs.). >>You simply compile the C and C++ as a shared library, provide a >>pointer to the library, define a few entry points in Lisp, and >>you're off. It is necessary that the main program be in Lisp >>and the C or C++ in a shared library.
>No No. l I want the other way around. I want to know if I can write code >in LISP and link it into a program i've written in C or C++. It shouldn't >matter what platform or implementation of anything I'm on, unless there are >only certain LISP compilers that can do this. C functions have a standard >calling convention. It's a matter of whether or not the LISP compiler can >compile it to a C function. All it really has to do is put the underscore >in front of a function name (of course i know nothing about LISP or how it >handles functions. the whole reason i started the thread is because i want >to know what i can and can't do with LISP, seeing as how i'm about to start >getting heavily into AI programming.) But just to clarify i'm using Windows >NT 4.0 and Visual Studio 6.0. So i want to write some functions in LISP, >compile them into a .DLL (using Allegro CL 5.0 more than likely) and call >one of these .DLL functions from my C++ program. Can this be done?
Definitely somewhat more problematic, as Lisp programs have some "expectations" as to their access to memory, and management thereof, particularly in the context of garbage-collectible objects.
For some insight, you might look at the model used by Guile, a SCM variant, for how it may be embedded into C applications, you might want to take a look at:
The basic point of the exercise is that any variables that you want to pull into the C/C++ side from the "Lisp side of the world" have to be specially accessed; variables that you want to push from the "C/C++ side" to the "Lisp side" must similarly be carefully defined so that garbage collection sees them in an appropriate light.
-- [In response to deprecations of the use of <linux/*.h>] ...I prefer code that only compiles on Linux... I really don't care to help other operating systems grow. -- Albert D. Cahalan <acaha...@saturn.cs.uml.edu> cbbro...@hex.net- <http://www.hex.net/~cbbrowne/lsf.html>
Zachary Turner wrote: > [..] But just to clarify i'm using Windows > NT 4.0 and Visual Studio 6.0. So i want to write some functions in LISP, > compile them into a .DLL (using Allegro CL 5.0 more than likely) and call > one of these .DLL functions from my C++ program. Can this be done?
Yes. ACL 5 can compile into DLL format. ACL 5 has just about everything that a lot of folks in this newsgroup have been clamoring for; I strongly recommend that anyone who's thinking about doing Windows development give it a look.