[Cffi-devel] Fw: Casting variables and functions

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Mon Mar 31 17:19:02 UTC 2014


On Sun, 2014-03-30 at 08:14 -0700, Joeish W wrote:
> I was just wondering why cffi doesn't do automatic conversions.

One reason may be that the FFI of the underlying Lisps (some? all?)
don't do automatic conversions.  They signal an error instead.
If some library always wraps values with additional calls
like (COERCE ,X 'FLOAT), it'll cost performance in general.
Advanced type-inferencing compilers like cmucl/sbcl might be able
to eliminate that extra call, depending on context.  But there's no reason
to let CFFI impose an extra performance burden on other implementations.

Of course, that implies that mismatching int and float in "portable CFFI code"
is unspecified, because the behaviour of the underlying FFI is
-- presumably -- not the same across all Lisps.  Some definitely
signal an error, perhaps some will silently coerce.

Regards,
	Jörg Höhle



More information about the cffi-devel mailing list