Command–query separation principle [re: @mustuse as a function attribute]

mw mingwu at gmail.com
Wed Oct 19 16:42:54 UTC 2022


On Wednesday, 19 October 2022 at 16:37:51 UTC, rikki cattermole 
wrote:
> On 20/10/2022 5:31 AM, mw wrote:
>> if a method is marked as @mustuse anywhere in the inheritance 
>> tree, that method in all the class levels in the whole 
>> inheritance tree became @mustuse!
>
> Unfortunately people don't compile their program all at once.

No, that's a limitation of current D compiler, or the build 
system dub.

Yes, for this logic to work, every compilation need to do global 
system analysis (that is what Eiffel compiler does).

Now the compiler writer have to work harder to implement this 
logic. Do not compromise!



> So therefore this won't work.
>
> I considered something along these lines, but its ultimately 
> error prone to try to force an attribute on for a class 
> hierarchy (including not allowing casts to parents).




More information about the Digitalmars-d mailing list