On Thu, Feb 14, 2008 at 7:00 PM, Joel Stanley jstanley@galois.com wrote:
Is there a finalizer registration mechanism available in Poly/ML that I can use to invoke appropriate tear-down functions in the C library when Poly/ML is done with the wrapped vol? If not, is there a weak pointer mechanism available that would allow me to accomplish the same?
I don't know, but a quick grep over Poly/ML's code base reveals that gc.cpp mentions weak references a number of times.
I do know, however, that MLton (http://mlton.org) supports both finalizers (http://mlton.org/MLtonFinalizable) and weak pointers (http://mlton.org/MLtonWeak). MLton also provides a straightforward low-level FFI (http://mlton.org/ForeignFunctionInterface) and ML-NLFFI (http://mlton.org/MLNLFFI). MLton's library repository (http://mlton.org/cgi-bin/viewsvn.cgi/mltonlib/trunk/) contains a few libraries (e.g. bindings to SQLite, SDL, and Windows API) making use of finalizers and both FFIs.
It would be nice to have a port of ML-NLFFI to Poly/ML, which, I believe, should be doable on top of Poly/ML's existing FFI.
-Vesa Karvonen