Object.toString, toHash, opCmp, opEquals

H. S. Teoh hsteoh at qfbox.info
Wed Jun 5 18:10:33 UTC 2024


On Wed, Jun 05, 2024 at 05:42:20PM +0000, Quirin Schroll via Digitalmars-d wrote:
> On Friday, 26 April 2024 at 18:28:00 UTC, Per Nordlöw wrote:
> > On Thursday, 25 April 2024 at 23:06:27 UTC, Walter Bright wrote:
> > > The prototypes are:
> > > 
> > > ```
> > > string toString();
> > > size_t toHash() @trusted nothrow;
> > > int opCmp(Object o);
> > > bool opEquals(Object o);
> > > ```
> > > 
> > > which long predated `const`. The trouble is, they should be:
> > 
> > Shouldn't some or all of them be qualified as scope aswell?
[...]
> However, I’m with Timon here, that those shouldn’t be forced onto the
> user.  Ideally, `Object` is empty (devoid of any functions) and there
> is an optional-to-inherit-from class or a mixin template that adds all
> those functions with some default implementation which is `@safe`,
> too.

We've talked about ProtoObject literally for years.  When are we going
to actually implement it?


T

-- 
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth


More information about the Digitalmars-d mailing list