Getting the const-correctness of Object sorted once and for all
Stewart Gordon
smjg_1998 at yahoo.com
Sun May 13 10:02:38 PDT 2012
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.
More information about the Digitalmars-d
mailing list