On Tuesday, 22 November 2022 at 20:36:51 UTC, []() {}() wrote:
From a software engineering perspective, what justification can their possibly be, for allowing (by default, and with no language mechanism to prevent it) any code in the same module as this class (including a tightly coupled, but otherwise fully specificed class), to override the specification of this class? How does that enhance encapsulation, as argued in that article?
public synchronized class Counter { static import core.atomic; private: int count = 0; public: void incrementCounter() { if ((count + 1) < 0) { // you might want to handle this } else core.atomic.atomicOp!"+="(this.count, 1); } int displayCounter() { return count; } }