DIP 1038--"@mustUse" (formerly "@noDiscard")--Accepted

Walter Bright newshound2 at digitalmars.com
Mon Feb 7 23:38:11 UTC 2022


On 2/6/2022 7:17 AM, Paul Backus wrote:
> To be honest, though, I can see where he's coming from. When writing DIP 1038, I 
> made a conscious effort to avoid using the term "non-`@nodiscard`", due to the 
> double negative. With a positively-phrased name like `@mustUse`, that problem 
> disappears.

Andrei once asked me for scientific evidence that negations are cognitively more 
difficult for human brains to understand. I didn't have it at the time, but did 
eventually find it and forwarded it to Andrei, who was satisfied with it. I 
didn't keep a copy, though.

It's not just my opinion that negations are to be avoided, there's research 
justifying it.

I remember back in the olden daze when I was designing digital logic circuits 
that using NAND and NOR gates would cause me endless confusion. I eventually 
decided to design with AND and OR gates, then mechanically convert them to NAND 
and NOR using deMorgan's Theorem.

NANDs and NORs require fewer transistors to function, so are preferred.

This was later built into the ABEL programming language that I designed for Data 
I/O. ABEL was used to burn logic equations into programmable logic devices. It 
had a pass that converted everything to NANDs and NORs.

Positive logic in computer code, however, has no such penalty. Hence I try to 
write code that eschews negative logic.

Anytime you find yourself writing not-nohow, not-noway, etc., it's time to 
redesign the state of the variables. Try to organize logic so ! is not 
necessary. I mean, try to organize logic so ! is absent.


More information about the Digitalmars-d-announce mailing list