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

mw mingwu at gmail.com
Wed Oct 19 18:00:39 UTC 2022


On Wednesday, 19 October 2022 at 17:46:15 UTC, Paul Backus wrote:
> You have this completely backwards. A derived class may 
> **remove** `@mustuse`, but can never **add** it.

look like I didn't get a good sleep last night :-)

As to the two propagation directions, if we analyzed it 
individually, H. S. Teoh's post has covered both the scenarios.


But I believe you got my point: we need global system propagation 
here as I showed in the previous post:

if you think about the global system analysis as a whole, it will 
work, and consistently. Yes, what I proposed is transitive 
closure:

     /--------Base------\
     |        |         |
Derived1   Derive2  Derive3
     |        |         |
GrandDr1   DrandRr2 GradDr3
     |
    ....

If the programmer *only* manually marked Derive3.remove() as 
@mustuse, everything else (Base, Derived1   Derive2  Derive3, 
GrandDr1   DrandRr2 GradDr3, ...
)'s .remove() method will become @mustuse (as seen by the 
compiler internally).





More information about the Digitalmars-d mailing list