Getting the const-correctness of Object sorted once and for all

Alex Rønne Petersen xtzgzorex at gmail.com
Sun May 13 10:04:59 PDT 2012


On 13-05-2012 19:02, Stewart Gordon wrote:
> On 13/05/2012 17:41, Alex Rønne Petersen wrote:
> <snip>
>> I agree with everything but toString(). I'm afraid that forcing
>> toString() to be const
>> will have harm flexibility severely. Can't we do better, somehow?
>
> How exactly?
>
> If you're talking about memoization, it ought to be possible to make use
> of std.functional.memoize to implement it.
>
> Otherwise, using toString to change the state of an object is bending
> semantics. If you want a method to generate a string representation of
> an object in a way that might do this, then create your own method to do
> it.
>
> Stewart.

But how would you memoize the value in the instance of the object if 
it's const?

-- 
- Alex


More information about the Digitalmars-d mailing list