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

Jonathan M Davis jmdavisProg at gmx.com
Mon Mar 18 16:05:56 PDT 2013


On Monday, March 18, 2013 23:53:05 Timon Gehr wrote:
> On 03/18/2013 11:11 PM, Stewart Gordon wrote:
> > ...
> > 
> > But the drawback of this approach (compared with making Object
> > const-correct) is that some library programmers will (continue to)
> > neglect const-correctness
> 
> That's a C++ term and it is not applicable to D.

I wouldn't go that far. I think that the term is still quite applicable to D, 
but given how much stricter D's const is, the situation is certainly quite 
different with regards to when it does and doesn't make sense to use const. But 
it's still best to make things const whenever they can be, which is the whole 
idea behind const-correctness. It's just that that happens less often in D 
than it does in C++.

- Jonathan M Davis


More information about the Digitalmars-d mailing list