== operator

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 4 16:37:41 PST 2015


On Saturday, January 03, 2015 19:37:16 Andrei Alexandrescu via Digitalmars-d wrote:
> On 1/3/15 7:23 PM, anonymous wrote:
> > For reference, here is .object.opEquals (according to documentation[1]):
> >
> > bool opEquals(Object a, Object b)
> > {
> >      if (a is b) return true;
> >      if (a is null || b is null) return false;
> >      if (typeid(a) == typeid(b)) return a.opEquals(b);
> >      return a.opEquals(b) && b.opEquals(a);
> > }
> >
> > I see one fundamental source of overhead: The types degenerate to
> > Object, resulting in virtual calls that could be avoided. Maybe it'd be
> > worthwhile to templatize object.opEquals: `bool opEquals(A, B)(A a, B b)`.
>
> Good point. It's been discussed but rejected because druntime generally
> shuns templates. I think that resistance is mostly vestigial by now.

It needs to happen as part of getting opEquals and friends off of Object,
but a Win32 compiler bug is currently preventing it from happening:

https://github.com/D-Programming-Language/druntime/pull/459
https://issues.dlang.org/show_bug.cgi?id=12537

Unfortunately, none of the compiler devs seem to have taken any notice of
it, and I haven't had the time or expertise to figure it out myself.
Otherwise, it probably would have been templatize before the last dconf.

- Jonathan M Davis



More information about the Digitalmars-d mailing list