Rich Neswold <rich.nesw...@gmail.com> writes:

> On Tue, Feb 9, 2010 at 12:45 PM, Tiphaine Turpin <tiphaine.tur...@irisa.fr>
> wrote:
>
>     Here is an adaptation of your example.
>
>
> Thank you! I'll experiment with your example to see if I can use it (like you
> said, it may be too complicated to add to the API.) Regardless, it was an
> interesting lesson and taught me a little more about the language.
>
> Thanks again,

Why not make the context a custom block with finalizer? The finalizer
then frees the resources. If the context escapes then it remains alive
and the finalizer will not be called any time soon. Only when it is no
longer reachable. That would also allow someone to create a context and
use it for a number of operations before forgeting it.

The drawback is that the finalizer will only be called when the GC runs
at some later time. If you need the resources to be freed right there
then it won't help.

MfG
        Goswin

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to