[MLton-user] opaque types and ffi

Matthew Fluet fluet@cs.cornell.edu
Tue, 25 Nov 2003 10:00:50 -0500 (EST)


> About practical matters, I did not know about MLton.pointer.
> Is an ffi call required for testing for null pointer? Vesa

It depends on what SML type you use to represent the pointer.  Obviously,
you can compare a Word32.word with 0wx00 without leaving SML.  On the
other hand, as Tom pointed out, the MLton.pointer type has no SML side
operations; it can only be passed to and from FFI calls.  So, you would
need to dispatch to C to test a MLton.pointer for null.

There is an isNull function that is used in the implementation of the
basis-library.  It would be easy enough to export it in the MLton
structure as:
  val isNull : pointer -> bool