Re: [Sbcl-help] Best way to send lisp functional values to C?

Marco Antoniotti <marcoxa@...> writes:
> On May 8, 2007, at 12:17 PM, Vadim Konovalov wrote:
>>>> John McCaw wrote:
>>>>
>>>>> I noticed that some other lisp versions have a dll export that
>>>>> you can use with C/C++. I did not read any such information
>>>>> about sbcl.
>>
>> which lisp versions are you refering to?
>
> LW does it. Allegro does too. Among the "free" implementations ECL
> (http://ecls.sf.net) was built exaclty with that goal in mind.
Clisp can also be used this way, I think.

Thread view

Hello,
I noticed that some other lisp versions have a dll export that you can
use with C/C++. I did not read any such information about sbcl. I was
wondering if anyone out there had experience of integrating sbcl lisp
into C and if they had any sample code.
thanks,
John

Hi!
> I noticed that some other lisp versions have a dll export that you can =
> use with C/C++. I did not read any such information about sbcl. I was=
=20
> wondering if anyone out there had experience of integrating sbcl lisp=20
> into C and if they had any sample code.
You should give CFFI a try:
http://common-lisp.net/project/cffi/
SWIG (http://www.swig.org/) can be used to generate the wrappers.
Greetings
Marc

Nikodemus Siivola <nikodemus@...> writes:
> John McCaw wrote:
>> Hello,
>> I noticed that some other lisp versions have a dll export that you can
>> use with C/C++. I did not read any such information about sbcl. I was
>> wondering if anyone out there had experience of integrating sbcl lisp
>> into C and if they had any sample code.
>
> See the fine manual:
>
> http://www.sbcl.org/manual/Foreign-Function-Interface.html#Foreign-Function-Interface
It doesn't seem to me that this answers the original question. I
think a better answer is that there is no provision currently to turn
SBCL functionality into a library in the usual sense of being able to
link to it from C. The manual section that Nikodemus refers to is
about being able to link in C libraries to a lisp environment, which
may be enough for certain needs.
Cheers,
Christophe

Christophe Rhodes wrote:
> Nikodemus Siivola <nikodemus@...> writes:
>
>
>> John McCaw wrote:
>>
>>> Hello,
>>> I noticed that some other lisp versions have a dll export that you can
>>> use with C/C++. I did not read any such information about sbcl.
which lisp versions are you refering to?
None of lisp implementations that I know provide such shared libraries
(dll export or whatever), rather these are standalone executables which
happen to use some image file.
(my knowledge in lisp is limited, so I could be wrong)
This means you usually do other way round - call your C application from
LISP and this ways establish a connection.
Some lisp could provide static libraries for linkage, however. (like
"linking set" in CLISP)
>>> I was
>>> wondering if anyone out there had experience of integrating sbcl lisp
>>> into C and if they had any sample code.
>>>
>> See the fine manual:
>>
>> http://www.sbcl.org/manual/Foreign-Function-Interface.html#Foreign-Function-Interface
>>
>
> It doesn't seem to me that this answers the original question. I
> think a better answer is that there is no provision currently to turn
> SBCL functionality into a library in the usual sense of being able to
> link to it from C. The manual section that Nikodemus refers to is
> about being able to link in C libraries to a lisp environment, which
> may be enough for certain needs.
>
>
Vadim.

Marco Antoniotti <marcoxa@...> writes:
> On May 8, 2007, at 12:17 PM, Vadim Konovalov wrote:
>>>> John McCaw wrote:
>>>>
>>>>> I noticed that some other lisp versions have a dll export that
>>>>> you can use with C/C++. I did not read any such information
>>>>> about sbcl.
>>
>> which lisp versions are you refering to?
>
> LW does it. Allegro does too. Among the "free" implementations ECL
> (http://ecls.sf.net) was built exaclty with that goal in mind.
Clisp can also be used this way, I think.

On May 8, 2007, at 12:17 PM, Vadim Konovalov wrote:
> Christophe Rhodes wrote:
>> Nikodemus Siivola <nikodemus@...> writes:
>>
>>
>>> John McCaw wrote:
>>>
>>>> Hello,
>>>> I noticed that some other lisp versions have a dll export that
>>>> you can
>>>> use with C/C++. I did not read any such information about sbcl.
>
> which lisp versions are you refering to?
LW does it. Allegro does too. Among the "free" implementations ECL
(http://ecls.sf.net) was built exaclty with that goal in mind. I
think I remember someone dabbling with SBCL (or was it CMUCL?!?) to
achieve the same effect.
Cheers
--
Marco

Marco Antoniotti wrote:
> On May 8, 2007, at 12:17 PM, Vadim Konovalov wrote:
>
>
>> Christophe Rhodes wrote:
>>
>>> Nikodemus Siivola <nikodemus@...> writes:
>>>
>>>
>>>
>>>> John McCaw wrote:
>>>>
>>>>
>>>>> Hello,
>>>>> I noticed that some other lisp versions have a dll export that
>>>>> you can
>>>>> use with C/C++. I did not read any such information about sbcl.
>>>>>
>> which lisp versions are you refering to?
>>
>
> LW does it. Allegro does too. Among the "free" implementations ECL
> (http://ecls.sf.net) was built exaclty with that goal in mind.
very much thanks for opening my eyes :)
> I
> think I remember someone dabbling with SBCL (or was it CMUCL?!?) to
> achieve the same effect.
>
IMO any package providing static libraries is "prepared" for dynamic
loading also.
DLL-wrapper for windows is easy.
With best regards,
Vadim.