[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FFI and disjoint types
From: |
Andy Wingo |
Subject: |
Re: FFI and disjoint types |
Date: |
Wed, 03 Mar 2010 13:24:03 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) |
Hi,
On Mon 01 Mar 2010 15:18, address@hidden (Ludovic Courtès) writes:
> With ‘(system foreign)’, C pointers are mapped to Scheme foreign
> objects, regardless of the type of object pointed to. Thus, to get
> disjoint types in Scheme, foreign objects would need to be boxed in
> structs (since structs are the only way to create disjoint types from
> Scheme).
>
> If this analysis is correct
It is
> the resulting code may be somewhat
> inefficient since we end up boxing C pointers twice.
Do you think this is an issue? We could add an extra word to foreign
pointers to make them have a type tag; or we could change the foreign
pointer representation to have a vtable. The downside with that is that
you can't allocate static foreign pointers that way.
I have a feeling that "double-wrapping" will perform fine. I figure a
high-level FFI will wrap these primitive foreign pointers in such a way
that they can preserve typing information, and hide the primitive
foreign pointer (if appropriate). But I could be wrong about that!
Cheers,
Andy
--
http://wingolog.org/