Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top