Command–query separation principle [re: @mustuse as a function attribute]
mw
mingwu at gmail.com
Wed Oct 19 19:05:59 UTC 2022
On Wednesday, 19 October 2022 at 18:56:35 UTC, Paul Backus wrote:
> On Wednesday, 19 October 2022 at 18:38:55 UTC, mw wrote:
>
> It is possible to achieve both. If the compiler enforces the
> rules I laid out in my initial post [1] (i.e., inheritance can
> only remove @mustuse, not add it),
This won't work as Teoh has showed the loophole:
1) Base class has @mustuse, derived class does not. Then the
base class's @mustuse can be circumvented by a derived class that
omits the attribute, defeating the purpose of @mustuse in the
base class.
> Of course, this means that there will be some functions that
> can never be marked as @mustuse without a breaking change--just
> like with @safe and nothrow. But that's true even with your
> proposal.
In any case it will be a breaking change, I never said otherwise;
and it's not of my concern. My only concern is how to make the
ideal D code more robust.
More information about the Digitalmars-d
mailing list