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

Jonathan M Davis jmdavisProg at gmx.com
Tue Mar 19 21:38:55 PDT 2013


On Tuesday, March 19, 2013 20:51:28 Stewart Gordon wrote:
> But the question still remains: How do we implement this change without
> causing mass disruption?  It might be the case that programmers just
> need to remove opEquals(Object) and opCmp(Object) from their classes,
> and remove the override attribute from toHash and toString (and declare
> them const as appropriate).  But there will be a lot of libraries to
> convert, and it will take time for them all to be converted.

I expect that we'll figure out how to do that when we're ready to actually 
start the transition process, but the obvious thing to do to start with would 
be to deprecate opEquals, opCmp, toHash, and toString on Object, which should 
then cause a number of deprecation warnings. That likely wouldn't be enough, 
but it would be a start. Additional compiler warnings would probably need to 
be added at some point, and eventually those functions would be outright 
removed. But regardless of how it's approached, it's obviously going to 
require changing existing code, and it's going to be disruptive. We can't 
avoid that, just mitigate it. But it _is_ a change that we're going to need to 
make in order to solve some of the problems surrounding opEquals et al and 
const. The main issue at this point is gettnig the work necessary to be able 
to make the transition done (and since that includes changes to the AA 
implementation, it's far from a small undertaking).

- Jonathan M Davis


More information about the Digitalmars-d mailing list