chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Choosing between FFI approaches


From: Thomas Chust
Subject: Re: [Chicken-users] Choosing between FFI approaches
Date: Tue, 01 Nov 2005 10:49:03 -0000
User-agent: Opera M2/8.02 (MacPPC, build 2148)

Am 31.10.2005, 21:32 Uhr, schrieb Peter BARABAS <address@hidden>:

[...]
B.)

(define-foreign-type dbtype int)
(define-foreign-variable db:unknown dbtype DB_UNKNOWN (->string DB_UNKNOWN))
(define db:unknown DB_UNKOWN)

Here the Scheme variable gets its value from the C variable DB_UNKNOWN

This approach has more abstraction (though it can be even more
abstract with a simple macro) and is more resistant to changes in the
C library. Does it have any disadvantages? This second method seems a
bit better for me.
[...]

As is often the case with higher abstraction, it causes more overhead on the
low level side. Everytime you acces the variable in example B, machine data
has to wrapped into or unwrapped from scheme data types -- with the int type in CHICKEN this should not cause noticeable performance losses, but with, for
example, double variables it would.

cu,
Thomas Chust




reply via email to

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