« Return to Thread: Feature request: MLton.Finalizable

Feature request: MLton.Finalizable

by John Reppy-2 :: Rate this Message:

Reply to Author | View in Thread

I'm using finalization as a backstop for explicit management
of resources (e.g., textures and shaders).  I typically use the type

        Int32.int option ref MLton.Finalizable.t

to represent these resources and set the ref to NONE when it
has been explicitly deallocated.  I could streamline this
process with the addition of the following two operations to
the Finalizable structure:

       (* remove all finalization functions from the object *)
        val cancelFinalizers : 'a t -> unit

       (* change the state of the finalized object *)
        val update ('a t * 'a) -> unit

The implementation is straightforward:

        fun cancelFinalizers (T{finalizers, ...}) = finalizers := []

        fun update (T{value, ...}, x) = value := x

Any chance of getting these added to MLton?

        - John


_______________________________________________
MLton-user mailing list
MLton-user@...
http://mlton.org/mailman/listinfo/mlton-user

 « Return to Thread: Feature request: MLton.Finalizable

LightInTheBox - Buy quality products at wholesale price!