www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Question about memoize

reply "Richie" <richie 4rensics.org> writes:
I've pasted a code sample here with a comment of what should be 
printed out: http://dpaste.dzfl.pl/02cfc280

memoize is taken straight from std.functional, I just added a 
writeln so I could see more about what was going on. 
slowFuncString should only be calculated twice with the input 
given: Once for "Test1" and once for "Test2" but it's being 
calculated every time. The same answer will probably answer both 
of these questions but:

1) Why does p = null when the tuple of Test2 is in the memo AA?
2) How does memoize appear to be adding more than one of the same 
key to the memo AA?

Thanks.
Oct 03 2012
parent "bearophile" <bearophileHUGS lycos.com> writes:
Richie:

 2) How does memoize appear to be adding more than one of the 
 same key to the memo AA?

 Thanks.
I have not studied your code much, but maybe it's: http://d.puremagic.com/issues/show_bug.cgi?id=3789 But this problem is for structs, I think tuples don't have it. Bye, bearophile
Oct 04 2012