opEquals needs to return bool

Sean Kelly sean at invisibleduck.org
Fri May 16 07:44:41 PDT 2008


== Quote from Edward Diener (eddielee_no_spam_here at tropicsoft.com)'s article
> Steven Schveighoffer wrote:
> > "Steven Schveighoffer" wrote
> >> Because opEquals returns int, this breaks some generic code:
> >
> > Apparently I am not the only one who thinks so :)
> >
> > http://d.puremagic.com/issues/show_bug.cgi?id=1989
> >
> > Can someone please dispell this myth about performance and add it to this
> > bug report?
> One of the first things I mentioned on this NG when looking at D for the
> first time is to ask why opEquals returns 'int' instead of 'bool'. After
> being directed to a discussion about it and Walter's explanation of the
> reason I said that I hoped that he would come to his senses and realize
> it was just plain wrong. I have not changed my opinion one whit and I am
> glad that others also realize it is wrong. Hopefully Walter has realized
> it is wrong by this time too.
> IMO, even if it were so, one does not twist programming design for a
> performance gain.

For what it's worth, we tried changing this in Tango but it turns out that there
are some compiler changes needed as well.  I believe the problem we ran into
was that opEquals in structs stopped working properly, though I fail to
understand why the compiler would care about the return value of opEquals
for this feature.


Sean



More information about the Digitalmars-d mailing list