[MLton-devel] Re: [MLton-user] ffi pointer lifetime

Vesa A Norrman vnorrman@cc.hut.fi
Thu, 15 May 2003 17:29:37 +0300 (EEST)


> I propose the following solution to the problems of keeping the
> Word32.word alive as long as it is needed and to tracking dependencies
> between C structs.
>
> ------------------------------------------------------------
> signature FINALIZABLE =
>    sig
>       type 'a t
>
>       (* finalize (v, f) will run f () when the value in v is no longer used. *)
>       val finalize: 'a t * ('a -> unit) -> unit
>       (* finalizeBefore (a, b) requires a to be finalized before b. *)
>       val finalizeBefore: 'a t * 'b t -> unit
>       (* new x creates a new finalizable value.  The finalizers will be run
>        * after the last call to withValue.
>        *)
>       val new: 'a -> 'a t
>       (* withValue (v, f) returns the result of applying f to the value of v
>        * and ensures that v's finalizers will not run until f completes.
>        *)
>       val withValue: 'a t * ('a -> 'b) -> 'b
>    end
> ------------------------------------------------------------

Excelent! I was thinking to only have

val newfinalizedvalue : 'a * (unit -> unit) -> 'a t

and the withValue. This is superior to what I was asking for!

[snip]

> That's it.  Let me know what you think, and if it makes sense to
> eliminate MLton.Finalize and put this stuff in as MLton.Finalizable.

I think it makes a lot of sense. The idea of specifying finalization order
seems usefull. About the function finalize: Will it add a new finalizer or
replace the old one? I don't know what use that will be but I guess
flexibility is always good. Vesa
-- 
                                    /`---*\
                                   = ^ o ^ =
                                    `-----'


-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com

_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel