[MLton-user] Feature request: cleaner C pointer support

John Reppy jhr at cs.uchicago.edu
Wed Dec 30 12:45:02 PST 2009


I think that the existing support for C pointers (MLton.Pointer) and foreign-interface programming
could be improved by the addition of a module

	structure C_PtrDiff : INT

to complement the already existing (but undocumented) C_Size WORD structure.

Then, the MLTON_POINTER signature should have the following revisions:

  1) change the type of add to

	val add : t * C_PtrDiff.int -> t

  2) change the type of diff to

	val diff : t * t -> C_PtrDiff.int

  3) remove sub (since it is now redundant)

  4) change the type of sizeofPointer to

	val sizeofPointer : C_Size.word

  5) add the functions

	val toWord : t -> C_Size.word
	val fromWord : C_Size.word -> t

     (I know that these can be synthesized by add/diff and null pointers, but they are quite useful
     for FI programming).




More information about the MLton-user mailing list