memoize & __traits(compiles...)

John Chapman johnch_atms at hotmail.com
Fri Nov 23 11:46:11 UTC 2018


On Friday, 23 November 2018 at 11:29:24 UTC, Nicholas Wilson 
wrote:
> No, std.functional.memoize uses a hashtable to cache the 
> runtime results of calls to expensive functions.
>
> assuming that the example is not oversimplified and 
> generateFunc1 and generateFunc2 are functions, the compiler 
> doesn't do extra semantic analysis so the validity of the 
> functions is effectively cached.
>
> If they are templates (with parameters) then the compiler will 
> automatically memoize them (it too keeps a hashtable of 
> template instances).

Ah, that's good to know.


More information about the Digitalmars-d-learn mailing list