help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A toy example of embedding C code in lisp and vice versa


From: bolega
Subject: Re: A toy example of embedding C code in lisp and vice versa
Date: Wed, 08 Dec 2010 15:13:26 -0000
User-agent: G2/1.0

On Jun 12, 12:08 pm, bolega <gnuist...@gmail.com> wrote:
> Here is a link to a thread that discusses this topic but there is no
> complete example.
>
> http://objectmix.com/lisp/362409-howto-use-lisp-scripting-language-wi...
>
> Lars Lune has a good section on code by searching this string
>
> "On Tue, 18 Mar 2008 01:16:00 -0700, Blackguester wrote:"
>
> but his code is replaced with smileys and even source shows it. I
> could not muster the confidence as a newbie to go into it by myself.
> Unless a guru can guide and explain.
>
> http://common-lisp.net/project/cffi/http://common-lisp.net/project/cffi/manual/html_node/Tutorial.htmlhttp://www.sbcl.org/manual/Foreign-Function-Interface.html
>
> Should I pick SBCL or ECL ? I have a long term view.

http://www.sbcl.org/manual/Calling-Lisp-From-C.html#Calling-Lisp-From-C

8.7.4 Calling Lisp From C

Calling Lisp functions from C is sometimes possible, but is extremely
hackish and poorly supported as of SBCL 0.7.5. See funcall0 ...
funcall3 in the runtime system. The arguments must be valid SBCL
object descriptors (so that e.g. fixnums must be left-shifted by 2.)
As of SBCL 0.7.5, the format of object descriptors is documented only
by the source code and, in parts, by the old CMUCL INTERNALS
documentation.

Note that the garbage collector moves objects, and won't be able to
fix up any references in C variables. There are three mechanisms for
coping with this:

   1. The sb-ext:purify moves all live Lisp data into static or read-
only areas such that it will never be moved (or freed) again in the
life of the Lisp session
   2. sb-sys:with-pinned-objects is a macro which arranges for some
set of objects to be pinned in memory for the dynamic extent of its
body forms. On ports which use the generational garbage collector (as
of SBCL 0.8.3, only the x86) this has a page granularity - i.e. the
entire 4k page or pages containing the objects will be locked down. On
other ports it is implemented by turning off GC for the duration (so
could be said to have a whole-world granularity).
   3. Disable GC, using the without-gcing macro.


[Q] How easy is it to call ECL  http://sourceforge.net/projects/ecls/
from C ?

Any toy example of doing this ?

what type of problem set would advise us that we embed C in LISP and
where lisp in C ?

Some toy examples ? send me email if you will share thru private
correspondance only.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]