Am I evil for this?

Atila Neves atila.neves at gmail.com
Fri Oct 14 07:54:40 UTC 2022


On Thursday, 13 October 2022 at 20:28:52 UTC, solidstate1991 
wrote:
> So I watched this video:
>
> https://youtu.be/G6b62HmsO6M
>
> And Walter talked about using operator overloading for 
> nonstandard purposes.
>
> So in my collections library, I used it to implement set 
> operators, but since set operators don't exist in the D 
> standard (and require unicode, which would upset a lot of 
> people, especially those who don't know what Win + '.' does), I 
> had to use operators that have similar function in other spaces.
>
> I personally haven't used them yet in my projects (except for 
> the unittests), so it's not too late to remove them, but I 
> don't know if anyone else might be using them or not.
>
> Link to my library with an example offense: 
> https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L356

On Thursday, 13 October 2022 at 20:28:52 UTC, solidstate1991 
wrote:
> So I watched this video:
>
> https://youtu.be/G6b62HmsO6M
>
> And Walter talked about using operator overloading for 
> nonstandard purposes.
>
> So in my collections library, I used it to implement set 
> operators, but since set operators don't exist in the D 
> standard (and require unicode, which would upset a lot of 
> people, especially those who don't know what Win + '.' does), I 
> had to use operators that have similar function in other spaces.
>
> I personally haven't used them yet in my projects (except for 
> the unittests), so it's not too late to remove them, but I 
> don't know if anyone else might be using them or not.
>
> Link to my library with an example offense: 
> https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L356

AFAIC, operators are infix functions with funny names. I think 
Haskell got it this exactly right syntax-wise, but definitely not 
culture-wise given their abuse of operators. If you have to tell 
people that you "pronounce" `>>=` as "shove", well...

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
}
```


More information about the Digitalmars-d mailing list