<div class="gmail_quote">On Tue, Jan 4, 2011 at 4:05 AM, Andrew Wiley <span dir="ltr"><<a href="mailto:debio264@gmail.com">debio264@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Mon, Jan 3, 2011 at 10:15 PM, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I just added a higher-order function memoize to std.functional which I think is pretty cool. See the docs here:<br>
<br>
<a href="http://d-programming-language.org/cutting-edge/phobos/std_functional.html#memoize" target="_blank">http://d-programming-language.org/cutting-edge/phobos/std_functional.html#memoize</a><br>
<br>
I'm also thinking of adding that cutting-edge directory as a place for storing documentation for commits that are in flux but not officially released yet.</blockquote><div><br></div></div></div><div>Pretty sweet, but if I'm understanding this correctly, the memoized version of a pure function isn't pure, is it? Is there any way to get that to happen? </div>

</div><br>
</blockquote></div><div><br></div><div>memoize uses a static variable. Are static variables considered "global" as far as pure functions are concerned? If not, then I see no reason for it not to be pure, or am I missing something?</div>
<div><br></div>Additionally, I don't understand this:<div><br><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
"Technically the memoized function should be pure because <span class="d_inlinecode"><a name="memoize"></a>memoize</span> assumes it will always return the same result for a given tuple of arguments. However, <span class="d_inlinecode"><a name="memoize"></a>memoize</span> does not enforce that because sometimes it is useful to <a name="memoize"></a>memoize an impure function, too."</blockquote>
</blockquote><div><span class="Apple-style-span" style="font-family: Arial, Verdana, sans-serif; line-height: 25px; "><br></span></div><div>Wouldn't memoizing an impure function be a.. bug? It would return the same cached value when in fact it should have returned something else based on external factors. When can that be desirable?<br clear="all">
<br>-- <br>Atenciosamente / Sincerely,<br>Guilherme ("n2liquid") Vieira<br>
</div></div>