On Thursday, 27 September 2018 at 09:58:25 UTC, Jonathan M Davis
wrote:
For two types to be compared, they must be the the same type -
or they must be implicitly convertible to the same type, in
which case, they're converted to that type and then compared.
So, as far as D's design of comparison goes, there is no need
worry about comparing differing types. At most, you need to
worry about what implicit type conversions exist, and D isn't
big on implicit type conversions, because they tend to cause
subtle bugs. So, while they definitely affect comparison, they
don't affect anywhere near as much as they would in a language
like C++. In general, you're not going to get very far if
you're trying to make it possible to compare a user-defined
type against other types in D without explicitly converting it
first.
- Jonathan M Davis
That makes sense, but requiring types to be explicitly converted
before comparisons kinda throws sand on the cake when I'm
ostensibly trying to make things that interact seamlessly with
existing types.
"alias this" is still awesome, so it's usually fine regardless :)
Thanks for the explanation.