3 ms·
If I understand this correctly, this are not fat pointers as used in e.g. Rust, where instead of a pointer you'd be passing in an argument a struct with two poi
by tomp 11y ago
If I understand this correctly, this are not fat pointers as used in e.g. Rust, where instead of a pointer you'd be passing in an argument a struct with two pointers, one to the object and the other to the implementation of the interface/typeclass.
Instead, they're more akin to vtables in C++, i.e. placing a pointer to the interface at the beginning of the object, before the data.
I need to read the source (or generated code) to fully understand how they implemented support for multiple interfaces/typeclasses.
- ecma 11y agoI think you might be misunderstanding the intentions of this. AFAICT it's not a mechanism for supporting multiple interfaces, just a bit of a light trickery to get a length passed into functions within the limitations of array->pointer decay in C. It also helps avoid cases where a miscalculated n is passed by 'encapsulating' it with the data. Edit: I stand corrected. Just had a look over the source and this does a lot more than the OP link indicates. The Github README is more informative.