6 ms·
What are the downsides of keeping the public fields in a struct which is in turn embedded in a private struct created by the library? Inferring the "outer offse
by michaelg7x 3y ago
What are the downsides of keeping the public fields in a struct which is in turn embedded in a private struct created by the library? Inferring the "outer offset" could get irritating but it depends on your tolerance of additional complexity (in every public function...).
- haberman 3y ago> What are the downsides of keeping the public fields in a struct which is in turn embedded in a private struct created by the library? That seems similar to using "opaque {}", if I am understanding you correctly? I think either of those solutions could potentially work, at the cost of one explicit cast in each function that actually needs to access the data. I would love to know if this works well enough in practice.
- JonChesterfield 3y agoThe answer in C would be it constrains ordering/packing of fields, so you'd end up with N public/private wrappers and generally a lot of line noise, but I have a vague recollection that zig reorders fields as it sees fit anyway making that a non-issue