ProtoObject and comparison for equality and ordering

H. S. Teoh hsteoh at quickfur.ath.cx
Tue May 14 20:22:14 UTC 2019


On Tue, May 14, 2019 at 08:00:09PM +0000, Adam D. Ruppe via Digitalmars-d wrote:
> On Tuesday, 14 May 2019 at 19:34:12 UTC, Andrei Alexandrescu wrote:
> > In designing ProtoObject
> 
> I think ProtoObject should define *absolutely nothing*. If an object
> wants to be comparable, let it implement opEquals and opCmp itself
> (and this is D, we can use template mixins too).
[...]

Yeah, from the Dconf slides, I was under the impression that ProtoObject
is supposed to contain absolute nothing at all, with a bunch of optional
interfaces like Comparable, Hashable, Stringifiable, Synchronizable,
etc., that define the corresponding operations *for those classes that
need it*.

But going with the static approach is even better than using interfaces,
because then you can have the compiler infer attributes for opEquals,
opCmp, etc., without suffering the limitations of the current
Object.opXXX and the associated attributes.

So yeah, I also vote for the static approach.


T

-- 
Dogs have owners ... cats have staff. -- Krista Casada


More information about the Digitalmars-d mailing list