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

H. S. Teoh hsteoh at qfbox.info
Wed Oct 19 18:37:59 UTC 2022


On Wed, Oct 19, 2022 at 06:25:54PM +0000, Paul Backus via Digitalmars-d wrote:
> On Wednesday, 19 October 2022 at 18:16:39 UTC, mw wrote:
> > Yes, I know that. But this in my view is still a compiler
> > implementation issue: even in separate dub packages, as long as the
> > compiler visit that package, it need to propagate the attribute to
> > that package's relevant class.
> 
> My point is that, even if we assume it is possible to implement, it is
> still a bad idea, because it would introduce implicit coupling between
> modules where no coupling (explicit or implicit) previously existed.
> 
> I hope I do not have to explain to you why implicit coupling is a bad
> thing in software development.

If we really wanted to enforce @mustuse across dub packages, the
solution is to include it in the mangled type. That will force a link
error when methods don't match up.

Of course, changing mangling will also cause breakage of existing code.
:-D


T

-- 
Век живи - век учись. А дураком помрёшь.


More information about the Digitalmars-d mailing list