3 ms·
Sure, but it still goes against the grain of the language. You could write a similar article explaining why everyone who thinks C doesn't have automatic memory
by bjourne 3y ago
Sure, but it still goes against the grain of the language. You could write a similar article explaining why everyone who thinks C doesn't have automatic memory management are wrong. Opaque structs are relatively annoying to work with especially if sibling modules in the same package have good reasons to manipulate the private parts directly. It is not nearly as convenient as it is in a language with better support for encapsulation (e.g Java). Most of the C code I write do not encapsulate anything. It's not worth the bother. Especially not when unit-testing for which encapsulation would force you to write lots of redundant getters and setters just for the unit tests themselves. My view is that you simply shouldn't use C if you need encapsulation.