<div dir="ltr">I, for one, would love to have a compiler do (a) based on (b), my specification of (c), and the ability to pin particular things...<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 22, 2013 at 4:04 PM, wren ng thornton <span dir="ltr">&lt;<a href="mailto:wren@freegeek.org" target="_blank">wren@freegeek.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 7/22/13 9:06 AM, Tom Ellis wrote:<br>
&gt; On Mon, Jul 22, 2013 at 07:52:06PM +1200, Chris Wong wrote:<br>
</div><div class="im">&gt;&gt; A binding is memoized if, ignoring everything after the equals sign,<br>
&gt;&gt; it looks like a constant.<br>
&gt;&gt;<br>
&gt;&gt; In other words, these are memoized:<br>
</div>&gt; [...]<br>
<div class="im">&gt;&gt;      f = \x -&gt; x + 1<br>
</div>&gt; [...]<br>
<div class="im">&gt;&gt; and these are not:<br>
&gt;&gt;<br>
&gt;&gt;      f x = x + 1<br>
&gt;<br>
</div><div class="im">&gt; In what sense is the former memoised?  I&#39;m not aware of any difference<br>
&gt; between these two definitions.<br>
<br>
</div>Consider rather,<br>
<br>
    f1 = let y = blah blah in \x -&gt; x + y<br>
<br>
    f2  x = let y = blah blah in x + y<br>
<br>
The former will memoize y and share it across all invocations of f1;<br>
whereas f2 will recompute y for each invocation.<br>
<br>
In principle, we could translate between these two forms (the f2 ==&gt; f1<br>
direction requires detecting that y does not depend on x). However, in<br>
practice, the compiler has no way to decide which one is better since it<br>
involves a space/time tradeoff which: (a) requires the language to keep<br>
track of space and time costs, (b) would require whole-program analysis to<br>
determine the total space/time costs, and (c) requires the user&#39;s<br>
objective function to know how to weight the tradeoff ratio.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Live well,<br>
~wren<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>