<br><br><div class="gmail_quote">On 29 August 2012 15:21, Joachim Breitner <span dir="ltr">&lt;<a href="mailto:breitner@kit.edu" target="_blank">breitner@kit.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Facundo,<br>
<br>
Am Mittwoch, den 29.08.2012, 10:26 -0300 schrieb Facundo Domínguez:<br>
<div class="im">&gt; &gt;         upd_noupd n =<br>
&gt; &gt;             let l = myenum&#39; 0 n<br>
&gt; &gt;             in last l + length l<br>
&gt;<br>
&gt; This could be rewritten as<br>
&gt;<br>
&gt; &gt;         upd_noupd n =<br>
&gt; &gt;             let l n = myenum&#39; 0 n<br>
&gt; &gt;             in last (l n) + length (l n)<br>
&gt;<br>
&gt; Or a special form of let could be introduced to define locally-scoped macros:<br>
&gt;<br>
&gt; &gt;         upd_noupd n =<br>
&gt; &gt;             let# l = myenum&#39; 0 n<br>
&gt; &gt;             in last l + length l<br>
&gt;<br>
&gt; What&#39;s the strength of the {-# NOUPDATE #-} approach?<br>
<br>
</div>it does not require refactoring of the code. There is not always a<br>
parameter handy that you can use to prevent sharing, and using () for<br>
that sometimes fails due to the full-lazyness-transformation.<br>
<br>
And a locally-scoped macros would not help in this case:<br>
<br>
        test g n = g (myenum&#39; 0 n)<br>
<br>
Now you still might want to prevent the long list to be stored, but here<br>
it cannot be done just by inlining or macro expansion.<br></blockquote><div><br></div><div>Syntactically, I&#39;d prefer something that looks more like a function.  With a pragma it&#39;s difficult to see what expression it actually affects.  For example, we already have the special functions &quot;lazy&quot; and &quot;inline&quot;. Since avoiding updates essentially turns lazy evaluation into call-by-name you could call it &quot;cbn&quot;. Perhaps that suggests a different use case, though, so &quot;nonstrict&quot;, &quot;unshared&quot;, or &quot;nonlazy&quot; might be more self-explanatory.</div>

<div><br></div><div>I&#39;d also like to point out that avoiding updates can dramatically improve the kind of speedups my tracing JIT can achieve. In particular, on some benchmarks, it can optimise idiomatic Haskell code to the same level as stream fusion. I can simulate that by avoiding *all* updates (i.e., use call-by-name), but that would break some programs badly. (Technically, that&#39;s all legal, but I&#39;m pretty sure it breaks any &quot;tying-the-knot&quot; tricks.)</div>

<div><br></div></div>