[MLton] Type of _address?

Stephen Weeks MLton@mlton.org
Thu, 21 Jul 2005 08:50:00 -0700


> I am considering changing the _address syntax from:
> 	_address "x": MLton.Pointer.t;
> to:	_address "x": MLton.Pointer.t, int;

I am still not convinced of the need for this change.  I'm not against
it; I probably just don't understand the C world well enough.

Like Matthew, I find it disconcerting that the base type doesn't appear
in the result.  Even more disconcerting, the MLton internals don't
make use of it in any way.  Are we doing something wrong?  If it
matters so little to us, why does it matter so much to C?

In any case, if we go this way, because _address and _symbol are now
specified identically, I feel it argues more for my earlier
proposal that folds _address into _symbol

  _symbol "symbol" [define]: ptrTy, cbTy; 

which is of type  

  ptrTy * (unit -> cbTy) * (cbTy -> unit)

In addition to saving the duplication of the symbol name in cases
where both the address and either the getter or setter is needed, 
this has the nice benefit that from the SML programmers, there is no
disconcerting unused type.

To save Wesley from constantly changing #i to #j in the basis library
we could make _symbol be of record type.

  {get: unit -> cbTy, pointer: ptrTy, set: cbTy -> unit}

But in favor of concision and in the hope that we'll get it right
eventually, the tuple is probably best.