We need closures

Pierre-Alexandre Voye ontologiae at gmail.com
Mon Sep 8 11:34:14 UTC 2008


A better example :

You create a function of function :
- predicat_great_than min : INTEGER : {INTEGER;BOOLEAN} <-
(
 { i : INTEGER;
   i > min
 }
);

Its type is INTEGER -> ( INTEGER -> BOOLEAN) : you give it an integer, it
result a function of INTEGER -> BOOLEAN.

So you can specialize  your function

- great_than_10 : {INTEGER;BOOLEAN} := predicat_great_than 10;

You created a specialized function...

2008/9/8 Mildred Ki'Lya <ml.mildred593 at online.fr>

> Not really my saying (even if it could or was):
>
> http://notes-on-haskell.blogspot.com/2008/09/closures-are-coming.html
>
> Short summary, closures are being implemented in C (LLVM+clang,
> initiated by Apple for ObjectiveC)
>
> Basically, closures are functions that can be passed as values and that
> reference variables from outside of the function. The tricky part of
> implementing them is when the function is called at a moment where the
> variables it uses are no longer then.
>
> Imagine the Lisaac code:
>
>  - return_a_closure initial_value:INTEGER :{;INTEGER} <-
>  ( + count :INTEGER;
>    count := initial_value - 1;
>    {
>      count := count + 1;
>      count
>    }
>  );
>
>  - uses_a_closure <-
>  ( + closure :{;INTEGER};
>    closure := return_a_closure 1;
>    closure.value.println;  // 1
>    closure.value.println;  // 2
>    closure.value.println;  // 3
>    closure.value.println;  // 4
>  );
>
> Unfortunately, such code is likely to raise an error, the compiler
> saying that the BLOCK is used outside the variable 'count' scope.
>
> This is just to illustrate the concept of closure, not its usefulness.
>
> Mildred
> --
> Mildred Ki'Lya
> ╭───────── mildred593@online.fr ──────────
> │ Jabber, GoogleTalk: <mildred at jabber.fr>
> │ Site: <http://ki.lya.online.fr>              GPG ID: 9A7D 2E2B
> │ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B
>
> _______________________________________________
> Lisaac-devel mailing list
> Lisaac-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/lisaac-devel
>



-- 
---------------------
Isaac Project - http://isaacproject.u-strasbg.fr/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/lisaac-devel/attachments/20080908/70fe69ed/attachment.htm 


More information about the Lisaac-devel mailing list