[MLton-user] Weak pointer regression test 2
Ivan Tomac
ivan.tomac at gmail.com
Mon Apr 18 02:12:34 PDT 2011
On Sat, Apr 16, 2011 at 2:05 AM, Matthew Fluet <matthew.fluet at gmail.com>wrote:
>
> Well, the MLton.Finalizable structure is supposed to provide exactly
> those guarantees. It uses MLton.Weak under the hood, but in such a
> way that the object is not globalized. See
> http://www.mlton.org/MLtonFinalizable for an example.
>
> Indeed, one of the most common "mistakes" made with weak pointers is
> trying to make a "Word32.word MLton.Weak.t" object and believe that it
> can be used to free a C-side allocated resource; this doesn't work
> because the Word32.word is not a heap allocated object (in MLton), and
> so is considered always nulled.
>
Ah that's good to know. I wasn't sure if Finalizable had the same problems
as Weak. Probably should have also mentioned the reason I was using Weak and
not Finalizable was that support for weak pointers is more widespread
between different implementations.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton-user/attachments/20110418/01afdffd/attachment.htm
More information about the MLton-user
mailing list