<div dir="ltr">A better example :<br><br>You create a function of function :<br>- predicat_great_than min : INTEGER : {INTEGER;BOOLEAN} &lt;-<br>( <br>&nbsp;{ i : INTEGER;<br>&nbsp;&nbsp; i &gt; min<br>&nbsp;}&nbsp; <br>);<br><br>Its type is INTEGER -&gt; ( INTEGER -&gt; BOOLEAN) : you give it an integer, it result a function of INTEGER -&gt; BOOLEAN.<br>
<br>So you can specialize&nbsp; your function<br><br>- great_than_10 : {INTEGER;BOOLEAN} := predicat_great_than 10;<br><br>You created a specialized function...<br><br><div class="gmail_quote">2008/9/8 Mildred Ki&#39;Lya <span dir="ltr">&lt;<a href="mailto:ml.mildred593@online.fr">ml.mildred593@online.fr</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Not really my saying (even if it could or was):<br>
<br>
<a href="http://notes-on-haskell.blogspot.com/2008/09/closures-are-coming.html" target="_blank">http://notes-on-haskell.blogspot.com/2008/09/closures-are-coming.html</a><br>
<br>
Short summary, closures are being implemented in C (LLVM+clang,<br>
initiated by Apple for ObjectiveC)<br>
<br>
Basically, closures are functions that can be passed as values and that<br>
reference variables from outside of the function. The tricky part of<br>
implementing them is when the function is called at a moment where the<br>
variables it uses are no longer then.<br>
<br>
Imagine the Lisaac code:<br>
<br>
 &nbsp;- return_a_closure initial_value:INTEGER :{;INTEGER} &lt;-<br>
 &nbsp;( + count :INTEGER;<br>
 &nbsp; &nbsp;count := initial_value - 1;<br>
 &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp;count := count + 1;<br>
 &nbsp; &nbsp; &nbsp;count<br>
 &nbsp; &nbsp;}<br>
 &nbsp;);<br>
<br>
 &nbsp;- uses_a_closure &lt;-<br>
 &nbsp;( + closure :{;INTEGER};<br>
 &nbsp; &nbsp;closure := return_a_closure 1;<br>
 &nbsp; &nbsp;closure.value.println; &nbsp;// 1<br>
 &nbsp; &nbsp;closure.value.println; &nbsp;// 2<br>
 &nbsp; &nbsp;closure.value.println; &nbsp;// 3<br>
 &nbsp; &nbsp;closure.value.println; &nbsp;// 4<br>
 &nbsp;);<br>
<br>
Unfortunately, such code is likely to raise an error, the compiler<br>
saying that the BLOCK is used outside the variable &#39;count&#39; scope.<br>
<br>
This is just to illustrate the concept of closure, not its usefulness.<br>
<br>
Mildred<br>
--<br>
Mildred Ki&#39;Lya<br>
╭───────── mildred593@online.fr ──────────<br>
│ Jabber, GoogleTalk: &lt;<a href="mailto:mildred@jabber.fr">mildred@jabber.fr</a>&gt;<br>
│ Site: &lt;<a href="http://ki.lya.online.fr" target="_blank">http://ki.lya.online.fr</a>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPG ID: 9A7D 2E2B<br>
│ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B<br>
<br>
_______________________________________________<br>
Lisaac-devel mailing list<br>
<a href="mailto:Lisaac-devel@lists.alioth.debian.org">Lisaac-devel@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/mailman/listinfo/lisaac-devel" target="_blank">http://lists.alioth.debian.org/mailman/listinfo/lisaac-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>---------------------<br>Isaac Project - <a href="http://isaacproject.u-strasbg.fr/">http://isaacproject.u-strasbg.fr/</a><br>
</div>