A Fresh Look at Comparisons, Take 2

Jason House jason.james.house at gmail.com
Fri Apr 18 11:16:08 PDT 2008


Janice Caron Wrote:

> On 18/04/2008, Jason House <jason.james.house at gmail.com> wrote:
> >  I'm sure you could say that foo must now declare its parameters as explicit, but requiring all functions that compare A's to have explicit parameters really starts to kill the whole utility of having a base class to begin with.
> 
> That's a good point, but again, nothing /requires/ explicit
> parameters. It's like anything else - if you desire the behavior, use
> it; if you don't, don't.
> 
> But that is a very good observation, yes. Well spotted.

That's not the only problem, just an example.  The types of problems are the same as virtual functions vs. non-virtual functions.  I think that if you can't rework the proposal to remove the use of "explicit", then there are likely going to be gotchas floating around somewhere.

It seems like proper execution of comparison operators is a lot like the double dispatch problem http://en.wikipedia.org/wiki/Double_dispatch



More information about the Digitalmars-d mailing list