Possible way to achieve lazy loading with const objects
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Sep 29 10:41:04 PDT 2011
On 9/29/11 10:39 AM, Steven Schveighoffer wrote:
> The runtime failure makes code that was not quite fully defined (i.e.
> cannot compare two const objects) to badly defined (you can compare
> them, but you get an exception), especially when a const version is
> *easy* to create. I mean, all you are doing is comparing two immutable
> strings, that should be doable using const. Now I have to nag the author
> of MyExistingClass to change his opEquals to const.
I agree with this characterization.
> Compare changing opEquals to const instead of just *adding* a const
> version of opEquals. With a straight change, the code doesn't compile
> and you put const on opEquals wherever it complains. Now it's still
> fully defined and runs the same as before. How is that a bad thing?
It's a bad thing because it breaks existing code.
Andrei
More information about the Digitalmars-d
mailing list