3

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.

1 Answer 1

2

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.

2
  • mosmlc doesn't quite work on the code: bash$ mosmlc -P full tick6s.sml File "tick6s.sml", line 76, characters 13-15: ! val _ = main(cx:real,cy:real,s:real,imgLocation:string);<EOF> ! ^^^^^^^ ! Unbound value identifier: cx
    – segfault
    Jan 3, 2010 at 11:52
  • it's working fine now. If anyone is interested, please click the link in my original question to see the revised code.
    – segfault
    Jan 3, 2010 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.