memoize

Simen kjaeraas simen.kjaras at gmail.com
Tue Jan 4 05:59:50 PST 2011


Guilherme Vieira <n2.nitrogen at gmail.com> wrote:

> @Walter: would it be hard/impossible for the compiler to look at memoize  
> and
> tell it exhibits pure behavior and is, thus, pure?

The simplest solution is this:

template memoize( alias fn ) {
     static if ( isPure!fn ) {
         pure auto memoize( ParameterTypeTuple!fn ) {
             // Blah!
         }
     } else {
         auto memoize( ParameterTypeTuple!fn ) {
             // Blah!
         }

     }
}


-- 
Simen


More information about the Digitalmars-d mailing list