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

Paul Backus snarwin at gmail.com
Wed Oct 19 22:03:05 UTC 2022


On Wednesday, 19 October 2022 at 21:13:00 UTC, mw wrote:
> On Wednesday, 19 October 2022 at 13:17:00 UTC, Paul Backus 
> wrote:
>>
>> In other words, you cannot introduce `@mustuse` in a derived 
>> class; it must be present in the base class.
>>
>
> I just realized that we two have different design motivations / 
> goals: my goal is allow programmers to add @mustuse annotation 
> to *any* methods that return values, and then make the whole 
> thing work (to simulate Eiffel behavior to the max extent). So 
> I need global analysis.
>
> While your goal is to add @mustuse to method in such a way, 
> which won't break current system (or with minimal impact), if 
> the impact is too big, e.g conflict with prebuilt binary, then 
> constraint the annotation in such a way that some of the 
> annotations are not allowed to avoid the conflicts.

The only problem with your goal is that Walter and Atila would 
never have accepted a proposal that actually achieves it. :)

If you are designing your own language, you can do whatever you 
want, but if you are contributing to an existing language, you 
have to work within the limits of what the project leaders will 
allow.

My goal was to make @mustuse as useful as possible while (a) 
remaining inside those limits, and (b) keeping it simple enough 
that I could implement it on my own.


More information about the Digitalmars-d mailing list