3

我想使用 mosmlc 将我的 ML 程序编译成可执行的二进制文件。但是,我找不到太多关于如何做到这一点的信息。

我想编译的代码在这里http://people.pwf.cam.ac.uk/bt288/tick6s.sml

cx,cy,s,imgLocation 是我想从命令行参数中获取的 4 个参数。例如,如果程序使用 name 编译mandelbrot,则 inputbash$mandelbrot -0.5 0.15 0.0099 image.png应该执行 main 函数。

4

1 回答 1

2

您应该能够将此代码放入文件foo.sml并运行

mosmlc -P full foo.sml

要获取您想要的命令行参数 function CommandLine.arguments,例如,

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

您必须编写自己的usage函数。


PS如果你可以访问mosmlc,你可能也可以访问 interactive mosml,它对helptype 有一个非常有用的功能string -> unit

于 2010-01-03T05:29:34.423 回答