[MLton-user] Feature request: MLton.Finalizable
John Reppy
jhreppy at mac.com
Mon Jun 2 07:29:16 PDT 2008
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
More information about the MLton-user
mailing list