Purity (D2 standard libraries / object.d)
Walter Bright
newshound1 at digitalmars.com
Fri Jan 9 15:11:17 PST 2009
Jason House wrote:
> Walter Bright Wrote:
>
>> Jason House wrote:
>>> When considering the standard library changes, I realized that
>>> object.d could change. I believe a pure opCmp or toString could
>>> break user code with impure versions of those functions. Would
>>> that kind of a change to object.d cause any real problems for D2
>>> users?
>> As Andrei pointed out, the trouble with making the Object functions
>> pure is if you want to do an override that caches its value.
>
> One could easily generalize that to mean non-final virtual functions
> should never be pure. Memoizaton is a pretty basic need. I thought
> that was in D's future. Is that not true?
Memoization and purity don't mix. For each function, you'll have to pick
which way you want to go. I don't see what that has to do with D's
future, though, the language allows either.
More information about the Digitalmars-d
mailing list