I’ll keep my thoughts brief here. I could go either way on usingnamespace
but I am leaning towards removing it.
usingnamespace
is a handy utility - it does a lot of work very quickly and it’s one of the most “intheritance-styled” things that we have in Zig. However, it’s more restrictive than inheritance in a good way. We can’t traffic in state with it in the form of injecting instance-level member variables.
The more time I’ve spent around implementation-injection facilities, the less I’ve come to like them. They are very useful from the perspective of an author, but as a reader I’ve often found them to make otherwise trivial refactors more annoying than they should be. They’re also a common source of sneaky bugs (probably less in the case of usingnamespace
than in the case of full-fledged inheritance).
I’ve proposed an alternative way of injecting dependencies here: Mixin alternative using const declarations