tags:

views:

135

answers:

1

I would like to compile my ML program into a executable binary using mosmlc. However, I could not find much information on how to do it.

The code that I'd like to compile is here http://people.pwf.cam.ac.uk/bt288/tick6s.sml

cx,cy,s,imgLocation are 4 arguments that I'd like to take from command line arguments. For instance, if the program is compiled with name mandelbrot, input bash$mandelbrot -0.5 0.15 0.0099 image.png should execute the main function.

+2  A: 

You should be able to put this code into a file foo.sml and run

mosmlc -P full foo.sml

To get the command-line arguments you want function CommandLine.arguments, so, e.g.,

val (cx, cy, s, imgLocation) = 
  case CommandLine.arguments () 
    of [a, b, c, d] -> (a, b, c, d)
     | _ -> (usage(); Process.exit Process.failure)

You'll have to write your own usage function.


P.S. If you have access to mosmlc, you probably also have access to the interactive mosml, which has an incredibly useful help function with type string -> unit.

Norman Ramsey
mosmlc doesn't quite work on the code: bash$ mosmlc -P full tick6s.smlFile "tick6s.sml", line 76, characters 13-15:! val _ = main(cx:real,cy:real,s:real,imgLocation:string);<EOF>! ^^^^^^^! Unbound value identifier: cx
Bo Tian
it's working fine now. If anyone is interested, please click the link in my original question to see the revised code.
Bo Tian