Le 14/05/2012 21:25, Mehrdad a écrit :
On Monday, 14 May 2012 at 19:13:30 UTC, deadalnix wrote:
Le 14/05/2012 21:04, Mehrdad a écrit :
On Monday, 14 May 2012 at 18:52:06 UTC, deadalnix wrote:
The only reason I'd see a toSting function as non pure or non const is
memoize. It can be tackled with lib support in phobos.
What are other uses cases ?
Not necessarily 'memoization' -- you could be instead querying
another object for this information, which may not be const.
(Say, a network connection.)
I'd argue that hiding such an operation in toString or similar stuff
is what you want to avoid.
Uhm, I beg to differ...
What, exactly, is wrong with asking a non-const object for your
toString() information?
Nothing, expect it make it impossible to get that information on
const/immutables objects.
Additionnaly, this operation isn't supposed to modify the object in any
meaningfull way, or perform complex operation like connecting a remote
database.