[MLton-user] Feature request: MLton.Finalizable
Matthew Fluet
fluet at tti-c.org
Tue Jun 3 11:06:21 PDT 2008
On Mon, 2 Jun 2008, John Reppy wrote:
> On Jun 2, 2008, at 7:05 PM, Matthew Fluet wrote:
>> On Mon, 2 Jun 2008, John Reppy wrote:
>> > The implementation is straightforward:
>> >
>> > fun cancelFinalizers (T{finalizers, ...}) = finalizers := []
>> >
>> > fun update (T{value, ...}, x) = value := x
>> >
>> > Any chance of getting these added to MLton?
>>
>> Your 'update' function doesn't work with the Finalizable implementation.
>> The finalization functions are invoked on the original value v used to
>> construct the finalizable value. The closure passed off to the GC handler
>> can't be closed over the reference cell pointed to by the weak pointer,
>> else the reference cell would always be live.
>
> That's a more serious objection, since I'm trying to avoid the extra level of
> indirection :(.
MLton can often flatten references into their containing structure. Since
the ref used by the weak pointer is not updated, it is a good candidate
container. So, while you may pay the indirection in the source code, the
executable may not.
More information about the MLton-user
mailing list