[MLton] Question about Library Calls

Ben Chambers bjchambers at gmail.com
Wed Nov 1 13:46:34 PST 2006


On 11/1/06, Matthew Fluet <fluet at cs.cornell.edu> wrote:
>
> > 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?

The Gamma-CFA code.

> > 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.

Hmm... ok.  So there isn't anything significantly different between
the factorial function and a similar function with that prints the
result, except for the FFI call?



More information about the MLton mailing list