4 ms·
That is what FFI is for, right? Native structures do whatever they want. When gluing to C code, you use your FFI primitives to express the interfaces; and the s
by kazinator 11y ago
That is what FFI is for, right? Native structures do whatever they want. When gluing to C code, you use your FFI primitives to express the interfaces; and the structures which are expressed there are made to correspond to the C layout in some way.
You generally don't want to be constraining how data structures work in a language so that they can be handed off to C code directly. (Unless perhaps you're writing a language that is nearly a C dialect or something.)
- ori_b 11y agoYou don't want to rearrange structs on every system call. That would be slow.
- tedunangst 11y agoI think the idea is you would use the "FFI" type throughout the program, perhaps embedded in a larger structure if you need to track additional data. The same thing is frequently done in C. Wire format data gets padded and __packed as necessary, and then that's usually the program representation as well.