Am I evil for this?

Walter Bright newshound2 at digitalmars.com
Fri Oct 14 18:29:10 UTC 2022


On 10/14/2022 12:54 AM, Atila Neves wrote:
> As Bjarne said once in response to complaints that operator overloading lets 
> people write code that doesn't do what you expect:
> 
> ```
> // notice how the code and the docs lie
> /**
>   * Adds two numbers
>   */
> int sum(int i, int j) {
>      return i - j;  // oops
> }
> ```

True that documentation often (always?) lies about what the code actually does. 
But the causes of this are usually because of programmer laziness and/or error 
in documenting it correctly.

But operating overloading for non-arithmetic purposes is *deliberately* doing 
the unexpected.


More information about the Digitalmars-d mailing list