Why are opEquals/opCmp arguments not in or const for Objects?

Stewart Gordon smjg_1998 at yahoo.com
Sun Mar 17 17:53:52 PDT 2013


On 18/03/2013 00:34, Jonathan M Davis wrote:
> On Monday, March 18, 2013 01:20:40 Timon Gehr wrote:
>>>> So my question is "Why are the arguments to opEquals and opCmp (for
>>>> Objects) not declared in or const?".
>>>
>>> Because not all valid implementations can be. They shouldn't be in
>>> Object anyway.
>
> Yeah. It was agreed that opCmp, opEquals, toString, and toHash would be
> removed from Object, since they don't need to be there and cause unnecessary
> issues with const,

What are these "unnecessary issues with const" they cause?

I agree with doing away with Object.opCmp as it doesn't make sense to pretend that 
artibrary objects can be ordered in relation to each other.  Not sure about the others. 
But how would we go about this without causing far more disruption than making these 
methods const would?

> but AFAIK, no work has been done yet to make that that
> work. I would of the things that would likely have to be finished first would be
> the refactoring of the built-in AAs so that they're templated types
> internally, and I'm sure that there are similar roadblocks that will need to
> be sorted out. Long term though, none of that needs to be on Object and should
> be left to derived classes to add with whatever constness (or @safety or
> whatever) that is appropriate for them.

Why would some class want to implement these methods in a way that alters the object?

Stewart.

-- 
My email address is valid but not my primary mailbox and not checked regularly.  Please 
keep replies on the 'group where everybody may benefit.


More information about the Digitalmars-d mailing list