Purity (D2 standard libraries / object.d)
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Jan 9 20:01:38 PST 2009
Walter Bright wrote:
> 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.
Memoization and purity can and should go together. We need to sit down
and discuss that someday.
Andrei
More information about the Digitalmars-d
mailing list