[MLton] implement _address and _symbol

Wesley W. Terpstra wesley@terpstra.ca
Thu, 21 Jul 2005 22:13:46 +0200


On Thu, Jul 21, 2005 at 02:57:07PM -0500, Henry Cejtin wrote:
> The  argument  for  Pinned  comes  when the C code wants to do something
> that might cause a GC (i.e., it wants to run some ML code).  This is an
> aspect of the implementation of the C code.  Hence it should be handled by
> something in the C code, not by changing the interface to the C code.

That is indeed, one of the problem cases, and here C pins make sense.

> My  notion  would  be  that when the C code is going to call some ML code,
> it would register (pinning is fine for this) the objects it wants to refer
> to after the GC, then run the ML code, then (at some point) do the
> indirection off of the pinned things to get back the actual direct
> pointers.

I agree with you, there should be a C API.
There's nothing wrong from SML's point of view in your example.

> I don't see any point in having Pinned show up in ML code at all.

However, there remains the problem of _symbol "x": int vector;.
Since this *is* set from the SML side, perhaps here Pinned.t makes sense?

If I set "x" and later get "x", there's no guarantees at all that I get
the same object back. Not to mention, by the time I call C, it might 
already have moved.

-- 
Wesley W. Terpstra <wesley@terpstra.ca>