[MLton] filedes = int (was: Stack size?)

Matthew Fluet fluet@cs.cornell.edu
Mon, 11 Jul 2005 17:04:00 -0400 (EDT)


> > Now that there is a complete front-end, we could acheive the same by
> > 
> > -	datatype file_desc = FD of int
> > +	structure FD :> sig type t end = struct type file_desc = int end
> > +	type file_desc = FD.t
> 
> I like this solution, and it is used in other places in the basis
> library.  I'm tempted to make the change.
> 
> > Though I think there is still some advantage (though I'm hard
> > pressed to put my finger on exactly what the advantage is) to
> > requiring explicit pack and unpack functions to witness the
> > coercion.
> 
> This would only be at the FFI, right?

Yes, at which point you might be tempted to say that since FFI can peek 
through the abstraction and it is only safe to apply the coercion for the 
purposes of FFI, then it is actually more dangerous to expose the coercion 
functions where someone can get their hands on it.

However, more complicated FFI scenarios, say using NLFFI, might require 
building a C-struct with a file_desc component, at which point we would 
like to have the C-rep of a file_desc in hand.  So, there would likely 
still be a need for exposing the representation.