[Ecls-list] Lisp callback from C
Julian Stecklina
der_julian at web.de
Tue Aug 23 05:46:43 UTC 2005
On Tue, 23 Aug 2005 14:15:05 +0200
"Goffioul Michael" <goffioul at imec.be> wrote:
> > I doubt this is a very useful facility for general use. :)
>
> It would be nice then to think about how to implement it into ECL.
> The first things that come to my mind are (concept code):
> - let's take a simple example of
> (def-callback cb-plus ((a :int) (b :int)) :returning :int
> (+ a b))
> - this should be converted into a pure LISP function like:
> (defun <some-name> (a b)
> (+ a b))
> which is compiled, possibly making use of (declare (si::c-local))
> (indeed, in ECL, we cannot build C/LISP interaction without
> compilation)
> - a C wrapper should also be written, like
> int cb_plus(int a, int b) {
> return object_to_integer(<some-name>(make_integer(a),
> make_integer(b))); }
> - a foreign pointer can be constructed to get a reference to the
> callback ecl_make_foreign_data(@:void, 0, cb_plus)
>
> I have the impression that all the needed parts are already present
> in the compiler, but it requires some user-level interface and
> compiler hacking.
Compiler hacking should be minimal, I'll do a prototype.
Regards,
--
Julian Stecklina
(Of course SML does have its weaknesses, but by comparison, a
discussion of C++'s strengths and flaws always sounds like an
argument about whether one should face north or east when one
is sacrificing one's goat to the rain god.) -- Thant Tessman
More information about the ecl-devel
mailing list