[plt-scheme] Eli Barzilay's new FFI stuff

From: Christopher Armstrong (radeex at gmail.com)
Date: Sat Aug 7 10:44:19 EDT 2004

On Sat, 7 Aug 2004 02:33:49 -0400, Eli Barzilay <eli at barzilay.org> wrote:
> Now, note that since this is specifying simple memory layouts, you
> could in many cases fake it in the same way that you can do it in C:
>   (define-cstruct _substructname
>     ([super _structname]
>      [y _type]))
> The disadvantage is that to access the `x' slot of an instance of
> substructname, you have to use structname-x, which is confusing -- but
> this is fine because define-struct does just this. 

Well, that alone doesn't bother me, but in addition to this, it seems
I *also* have to ptr-ref the struct to the type that the slot is
defined on, which is frustrating.

(super-slot (ptr-ref obj  _super))

It's frustrating because I have really long slot and type names, and
that I'm duplicating the type-name in the same expression. Should I
just suck it up?

> The reason I said
> "many cases" is that I'm not sure if there can some alignment problems
> that will make `foo' have different layouts if you use:

Well, I asked some people knowledgeable in C and they said that there
shouldn't be any alignment issues, and that their equivalence is
defined by the ANSI standard...? If this is the case, then I
definitely don't need any special support in define-cstruct for
substructing; this is quite tolerable.


 Twisted | Christopher Armstrong: International Man of Twistery
  Radix  |          Release Manager,  Twisted Project
---------+            http://radix.twistedmatrix.com

Posted on the users mailing list.