From riccardo@CS.Cornell.EDU Sun Oct 28 01:14:45 2001 Date: Sun, 28 Oct 2001 01:09:01 -0400 From: Riccardo Pucella To: Jeffrey M. Vinocur Subject: Re: So how do we make ML actually do stuff? (fwd) +---------------------------------------------------------------------- | I haven't a clue what to tell this kid. Obviously people don't | need Emacs, but can SML actually produce binaries? Almost. Consider your favorite program. Assume it has a main function entry point, which for the sake of argument we'll call 'main'. It is a function of type (string * string list) -> OS.Process.status. It is a function that will take as its first argument argv[0], and as second argument the list [argv[1],...,argv[n]]. What you do is that you compile your program in SML/NJ. When you're ready to create your "binary", you call: SMLofNJ.exportFn ("somename",main); (of course, main could be in some structure, i.e. MyProgram.main, and it need not be called main, i.e. MyProgram.doit). This will spew out a heap image on disk, called somename.x86-unix for linux, similarly for others OSes) To "execute" this binary, you simply call: sml SMLload=somename and it will execute your program, without every giving you a prompt. To distribute, you only need the heap image (somename.-) and the runtime system (bin/.run/run.x86-unix). You can also call using run.x86-unix @SMLload=somename Hope that helps. - R -- Riccardo Pucella (riccardo@cs.cornell.edu) Department of Computer Science, Cornell University http://www.cs.cornell.edu/riccardo