Possible way to achieve lazy loading with const objects

Christophe travert at phare.normalesup.org
Thu Sep 29 06:32:06 PDT 2011


"Steven Schveighoffer" , dans le message (digitalmars.D:145729), a
>> I was arguing that opEquals (and co.) should *not* be const. IMO it  
>> would be a huge problem if they were.
> 
> why?  For what purpose do you need to change an object during comparison?

You may not need to change the object, but you may need to call a 
non-const method. It has been argued against the opponent to transitive 
const that they are not obliged to use const. Then opEqual should not 
oblige them to use const. const is so viral in D that people not willing 
to use const will have to change lines and lines of code to get opEqual 
working.

It is always possible for a non-const version of opEqual to forward to 
the const version, so people willing to use a const version do not have 
to define a non-const version.

-- 
Christophe


More information about the Digitalmars-d mailing list