struct opCmp confustion
Namespace
rswhite4 at googlemail.com
Sun Aug 26 16:30:20 PDT 2012
On Sunday, 26 August 2012 at 22:57:27 UTC, Era Scarecrow wrote:
> On Sunday, 26 August 2012 at 21:45:38 UTC, Namespace wrote:
>> Maybe I'm wrong but this method is never called by one of
>> these compares. Or is this the point?
>
> Mmmm you're right. Due to the re-writing I thought it would
> work. "abc" < "def" converts to "abc".opCmp("def") < 0, which
> then doesn't work so it rewrites to opCmp("abc", "def") < 0.
> Maybe I did it wrong; Or perhaps it's getting the values at
> compile-time and saving them (less likely).
>
>> I wished many times that something like this work, even for
>> other constructs. That would be a way to avoid nasty opCmp,
>> opEquals and so on in the object.d.
>
> Well unless whole functionality of certain types are required,
> writing a compare function for that particular case isn't so
> bad (or calling it in this case).
I prefer implicit calling. ;)
More information about the Digitalmars-d-learn
mailing list