[MLton] Question about Library Calls

Matthew Fluet fluet at cs.cornell.edu
Wed Nov 1 12:12:47 PST 2006


> So... after a long period of trying to debug the Gamma-CFA code that
> I've written, I've reached a point where I need to know a little bit
> more about MLton.  We've gotten it to run on a variety of test cases
> involving no application of the standard library (such as a factorial
> program that just computes the value of factorial, but doesn't print
> it).  When run on code that contains a print statement (even just
> hello world) it loops forever.

What "loops forever"?  The Gamma-CFA code or the final executable?

> I was wondering what you could tell me about how MLton implements the
> library call (such as the print statement), and what operations it
> performs that are not present in code that doesn't use any library
> calls.

Even your factorial function is using the Basis Library, in order to 
access the definitions of Int.- and Int.*.  Nonetheless, these kinds of 
functions become primitives (Prim.Name.Word_sub, Print.Name.Word_mul) in 
the compiler ILs.  Other Basis Library functions that correspond to 
interaction with the outside world (e.g., TextIO.print) are implemented 
via normal SML code plus some external C calls.  These external C calls 
also become primitives in the compiler ILs, but they are of the 
Prim.Name.FFI variant.



More information about the MLton mailing list