Hacker News new | ask | show | jobs
by kristoff_it 1173 days ago
It's impossible to state universally what should or should not be considered part of the public api of a struct when it comes to low-level programming.

In some cases the exact layout of the struct needs to stay stable. In others the contents don't matter, only that the size doesn't change. In others still, none of those properties matter and it's just a matter of keeping names and types stable, and that every new field that gets added has a default value so that old initialization expressions keep working.

This is just to name a few cases among many others. In the end you will need to specify in the docs what it is that you, the library author, want to consider part of the public API and what is considered an implementation detail.

Private fields could help with some of that, sure, but there are also big downsides. Andrew gave a while ago a good overview on the more "ziggy" perspective on the issue: https://github.com/ziglang/zig/issues/9909#issuecomment-9426...

1 comments

Awesome, I will do some more digging into this. Thanks for the thoughtful reply!