<div dir="ltr">A better example :<br><br>You create a function of function :<br>- predicat_great_than min : INTEGER : {INTEGER;BOOLEAN} <-<br>( <br> { i : INTEGER;<br> i > min<br> } <br>);<br><br>Its type is INTEGER -> ( INTEGER -> BOOLEAN) : you give it an integer, it result a function of INTEGER -> BOOLEAN.<br>
<br>So you can specialize 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'Lya <span dir="ltr"><<a href="mailto:ml.mildred593@online.fr">ml.mildred593@online.fr</a>></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>
- return_a_closure initial_value:INTEGER :{;INTEGER} <-<br>
( + count :INTEGER;<br>
count := initial_value - 1;<br>
{<br>
count := count + 1;<br>
count<br>
}<br>
);<br>
<br>
- uses_a_closure <-<br>
( + closure :{;INTEGER};<br>
closure := return_a_closure 1;<br>
closure.value.println; // 1<br>
closure.value.println; // 2<br>
closure.value.println; // 3<br>
closure.value.println; // 4<br>
);<br>
<br>
Unfortunately, such code is likely to raise an error, the compiler<br>
saying that the BLOCK is used outside the variable 'count' scope.<br>
<br>
This is just to illustrate the concept of closure, not its usefulness.<br>
<br>
Mildred<br>
--<br>
Mildred Ki'Lya<br>
╭───────── mildred593@online.fr ──────────<br>
│ Jabber, GoogleTalk: <<a href="mailto:mildred@jabber.fr">mildred@jabber.fr</a>><br>
│ Site: <<a href="http://ki.lya.online.fr" target="_blank">http://ki.lya.online.fr</a>> 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>