[Ecls-list] embedding: question regarding data structures?

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Fri Nov 13 21:54:45 UTC 2009


On Fri, Nov 13, 2009 at 10:31 PM, Rui Maciel <rui.maciel at gmail.com> wrote:
>
> Juan Jose Garcia-Ripoll wrote:
>> I would say you should not constrain yourself w.r.t to data
>> structures
>
> Sorry for asking you this but what does "w.r.t." stand for?

"with respect to", regarding to, etc

>> use whatever is best for your lisp programs.
>
> I guess that would be native CL data structures. On the other hand I already
> have a working C data structure and it appears that, unlike CL's structures,
> CLOS doesn't offer a way (at least a clean way) to enforce slot types. Could
> that pose some problems when accessing the data contained in CL's data
> structures from C?

CLOS objects store boxed lisp data. In other words, right now any slot
can store any kind of data. Even if you declare the slot type, that is
only a declaration, it has no real effect on the class itself.

>> If you want
>> you can compile lisp functions, such as structure slot readers or your
>> own custom writing functions, to have a C name that gets exported, and
>> use them directly from C, if you really need to (it is a
>> declaration, but I do not remember it right now).
>
> Sounds interesting. Is there any example that I can take a look?

Not yet, because the interface is not fixed. It would look as follows

foo.lsp:
(declaim (ext:c-export-fname ("my_function" my-function)))
(defun my-function (a b c)
  (print 1))

(compile-file "foo.lsp" :c-file "foo.c")

(ext:system "cat foo.c")

Notice how the function gets exported in the C code:

/*	Compiler: ECL 9.10.2                                          */
/*	Date: 2009/11/13 22:53 (yyyy/mm/dd)                           */
/*	Machine: Darwin 9.8.0 i386                                    */
/*	Source: foo                                                   */
#include <ecl/ecl-cmp.h>
#include "/Users/jjgarcia/src/ecl/build/foo.h"
/*	function definition for MY-FUNCTION                           */
cl_object my_function(cl_narg narg, cl_object V1, cl_object V2,
cl_object V3, ...)
{ VT2 VLEX2 CLSR2 STCK2
	const cl_env_ptr cl_env_copy = ecl_process_env();
[...]

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list