Subject: [clisp-list] dealing with structures in modules

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Thu Apr 11 09:36:59 2002

Hi,

Dan Stanger wrote:

> I have a function in a c module, which needs to return a 
> structure.  Is it possible to pass in the
> empty structure and set the elements of it? 

This sounds like
 (:arguments (foo (ffi:c-ptr (c-struct ...)) :out :alloca))

If you want to fill in prior to the call, use :in-out.

Are you sure you must return a struct, not a pointer to a struct?

> Or is it just as fast to return them as values,
I can't comment on performance. It very much depends on the exact (Lisp) code.

> and use a multiple-value-call passing them to a constructor for the
> structure.
> Or should I can I call the constructor directly in my c code.  The c
> code is being generated
> mostly, and I dont have too many structures, so I would prefer to do
> this in the most efficent way.

Generally, the more you can do (safely) in C wrappers, the faster.
Likewise, the more you can rely on built-in primitives (~500 of them), the faster.
For Lisp code in CLISP, there's always bytecode interpretation overhead.

My opinion: if you must write wrappers and cannot interface directly, then go ahead and make the return values and arguments as Lisp-friendly as possible (while in C wrapper code).

Regards,
	Jorg Hohle.