The in operator (along with other things) is designed poorly.

Nick Treleaven nick at geany.org
Tue May 31 17:45:17 UTC 2022


On Tuesday, 31 May 2022 at 00:57:43 UTC, Ruby The Roobster wrote:
> And what caused me to start writing the code that caused me to 
> make this thread is the fact that interfaces only require the 
> classes that inherit from them to implement virtual functions.  
> This means that if you want to require classes that inherit 
> from and interface to implement operator overloads, you can't 
> rely on the compiler to do it for you:  you have to use 
> __traits to make sure that those operator overloads exist.

It should be possible for the compiler to support operator 
overloads as virtual functions for each specific operator, as 
long as the runtime parameter types are fixed. That might require 
each operation to be listed as a separate overload though, 
`opBinary(string op: ”+”)`, `opBinary(string op: ”-”)` etc.


More information about the Digitalmars-d mailing list