Purity (D2 standard libraries / object.d)

Walter Bright newshound1 at digitalmars.com
Sat Jan 10 13:11:32 PST 2009


Andrei Alexandrescu wrote:
> Michel Fortin wrote:
>> On 2009-01-10 00:10:11 -0500, Andrei Alexandrescu 
>> <SeeWebsiteForEmail at erdani.org> said:
>>
>>>> The problem is identifying if this would be faster than recomputing 
>>>> the return value.
>>>
>>> I used memoizers for exp and log (the most called functions in some 
>>> code I wrote) and it made the original version feel like it was 
>>> driving in reverse.
>>
>> That's only true because, in your specific context, those functions 
>> were called often with the same input. In a program that rarely use 
>> the same inputs, your memoizing functions will just waste time and 
>> memory.
> 
> No, because I use interpolation.

That's way beyond the ability of a compiler to do automatically. The 
compiler would have to understand that the pure function produces 
continuous results.



More information about the Digitalmars-d mailing list