Does Common Lisp have a C interface?

This is a discussion on Does Common Lisp have a C interface? within the lisp forums in Programming Languages category; Hello, I am not a lisper - and just curious about the language, because it comes with quite a few concepts that are really nice... But one question, because this would be a knockout criteria for me to dive deeper into Lisp (if I had the time and need for that diving): Does CL or one of it's implementations have a C interface, so that one could integrate number crunching libraries and other neat stuff that is written in C? Thanks in advance E....

Go Back   Application Development Forum > Programming Languages > lisp

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 01-18-2008, 06:38 AM
EL
Guest
 
Default Does Common Lisp have a C interface?

Hello,

I am not a lisper - and just curious about the language, because it
comes with quite a few concepts that are really nice...

But one question, because this would be a knockout criteria for me to
dive deeper into Lisp (if I had the time and need for that diving):
Does CL or one of it's implementations have a C interface, so that one
could integrate number crunching libraries and other neat stuff that is
written in C?

Thanks in advance
E.
Reply With Quote
  #2  
Old 01-18-2008, 06:49 AM
Peter Hildebrandt
Guest
 
Default Re: Does Common Lisp have a C interface?

On Fri, 18 Jan 2008 12:38:03 +0100, EL <eckhardnospam@gmx.de> wrote:
> But one question, because this would be a knockout criteria for me to
> dive deeper into Lisp (if I had the time and need for that diving):
> Does CL or one of it's implementations have a C interface, so that one
> could integrate number crunching libraries and other neat stuff that is
> written in C?


http://common-lisp.net/project/cffi/

>
> Thanks in advance
> E.




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Reply With Quote
  #3  
Old 01-18-2008, 06:52 AM
John Thingstad
Guest
 
Default Re: Does Common Lisp have a C interface?

Pĺ Fri, 18 Jan 2008 12:38:03 +0100, skrev EL <eckhardnospam@gmx.de>:

> Hello,
>
> I am not a lisper - and just curious about the language, because it
> comes with quite a few concepts that are really nice...
>
> But one question, because this would be a knockout criteria for me to
> dive deeper into Lisp (if I had the time and need for that diving):
> Does CL or one of it's implementations have a C interface, so that one
> could integrate number crunching libraries and other neat stuff that is
> written in C?
>
> Thanks in advance
> E.


The bad news is that a C interface not defined in the standard.
The good news is that every Lisp implementation has one.
So to determine how to interface lisp to SO/DLL, COM, .NET, JNI you have
to consult the implementation documentation. There are also portable
layers above the native foreign function interface that allow portable
access do SO/DLL. Mainly the external libraries CFFI and UFFI.

--------------
John Thingstad
Reply With Quote
  #4  
Old 01-18-2008, 07:16 AM
EL
Guest
 
Default Re: Does Common Lisp have a C interface?

John Thingstad schrieb:

> The bad news is that a C interface not defined in the standard.
> The good news is that every Lisp implementation has one.
> So to determine how to interface lisp to SO/DLL, COM, .NET, JNI you have
> to consult the implementation documentation. There are also portable
> layers above the native foreign function interface that allow portable
> access do SO/DLL. Mainly the external libraries CFFI and UFFI.


Thanks for the fast answers...
CFFI and UFFI look good. Does anybody have experience with them - how
(easy) is type conversion - e.g. C structures <-> CL types & how is the
overall handling? Which one is more recomendable?

Or are the implementation specific interfaces better yet?


E.
Reply With Quote
  #5  
Old 01-18-2008, 07:19 AM
milanj@gmail.com
Guest
 
Default Re: Does Common Lisp have a C interface?

yes there is
look for "Foreign Function Interface"

http://www.sbcl.org/manual/Introduct...tion-Interface

btw. there is good enough CL implementation for that kind of stuff,
Sbcl for example
Reply With Quote
  #6  
Old 01-18-2008, 07:22 AM
Peter Hildebrandt
Guest
 
Default Re: Does Common Lisp have a C interface?

On Fri, 18 Jan 2008 13:16:05 +0100, EL <eckhardnospam@gmx.de> wrote:

> CFFI and UFFI look good. Does anybody have experience with them - how
> (easy) is type conversion - e.g. C structures <-> CL types & how is the
> overall handling? Which one is more recomendable?


I would recommend CFFI. It supports all major implementations. C
structs, types, callbacks and the like are handled quite nicely ("in a
lispy fashion" if you will: slot-value becomes foreign-slot-value etc.).
The online doc is very good.

I have some experience with CFFI and I like it, but probably you'll find
enough people who will say the same for UFFI.

> Or are the implementation specific interfaces better yet?


AFAIK CFFI is basically a common wrapper around the implementation
specific interfaces.

Peter

>
>
> E.



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Reply With Quote
  #7  
Old 01-18-2008, 08:54 AM
Ken Tilton
Guest
 
Default Re: Does Common Lisp have a C interface?



Peter Hildebrandt wrote:
> On Fri, 18 Jan 2008 13:16:05 +0100, EL <eckhardnospam@gmx.de> wrote:
>
>> CFFI and UFFI look good. Does anybody have experience with them - how
>> (easy) is type conversion - e.g. C structures <-> CL types & how is
>> the overall handling? Which one is more recomendable?

>
>
> I would recommend CFFI. It supports all major implementations. C
> structs, types, callbacks and the like are handled quite nicely ("in a
> lispy fashion" if you will: slot-value becomes foreign-slot-value
> etc.). The online doc is very good.
>
> I have some experience with CFFI and I like it, but probably you'll
> find enough people who will say the same for UFFI.


No, CFFI is basically a step beyond UFFI, functionally the next
generation and covering more Lisps, all Lisps for all intents and
purposes. Implementationally...
>
>> Or are the implementation specific interfaces better yet?

>
>
> AFAIK CFFI is basically a common wrapper around the implementation
> specific interfaces.


....in some case CFFI wraps the implementation FFI as does UFFI, in other
cases it digs a little deeper. I never actually looked very hard at the
mechanics, but I think the CFFI page offers some deets.

kt

--
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
Reply With Quote
  #8  
Old 01-20-2008, 08:05 AM
LuĂ­s Oliveira
Guest
 
Default Re: Does Common Lisp have a C interface?

EL <eckhardnospam@gmx.de> writes:
> CFFI and UFFI look good. Does anybody have experience with them - how
> (easy) is type conversion - e.g. C structures <-> CL types & how is
> the overall handling? Which one is more recomendable?


CFFI's documentation includes a nice tutorial written by Stephen Compall
that might address many of your questions. Quoting the first paragraph:

“Users of many popular languages bearing semantic similarity to Lisp,
such as Perl and Python, are accustomed to having access to popular C
libraries, such as GTK, by way of “bindings”. In Lisp, we do something
similar, but take a fundamentally different approach. This tutorial
first explains this difference, then explains how you can use CFFI, a
powerful system for calling out to C and C++ and access C data from
many Common Lisp implementations.”

<http://common-lisp.net/project/cffi/manual/html_node/Tutorial.html>

--
LuĂ*s Oliveira
http://student.dei.uc.pt/~lmoliv/
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:30 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.