我正在尝试编写命令行脚本,但 SML 的警告混淆了界面。
文档说要使用:
Compiler.Control.printWarnings := false;
但 SMLNJ 已将其重命名为:
Control.printWarnings := false;
这实际上产生了更多的打印输出。
例子:
$ cat hello.sml
print "Hello World!\n";
OS.Process.exit(OS.Process.success);
$ sml hello.sml
Standard ML of New Jersey v110.72 [built: Mon Nov 14 17:30:10 2011]
[opening hello.sml]
Hello World!
val it = () : unit
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[autoloading done]
hello.sml:2.1-2.36 Warning: type vars not generalized because of
value restriction are instantiated to dummy types (X1,X2,...)
相对:
$ cat hello.sml
Control.printWarnings := false;
print "Hello World!\n";
OS.Process.exit(OS.Process.success);
$ sml hello.sml
Standard ML of New Jersey v110.72 [built: Mon Nov 14 17:30:10 2011]
[opening hello.sml]
[autoloading]
[library $smlnj/compiler/current.cm is stable]
[library $smlnj/compiler/x86.cm is stable]
[library $smlnj/viscomp/core.cm is stable]
[library $smlnj/viscomp/basics.cm is stable]
[library $smlnj/viscomp/elabdata.cm is stable]
[library $smlnj/viscomp/elaborate.cm is stable]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $smlnj/viscomp/debugprof.cm is stable]
[library $SMLNJ-LIB/Util/smlnj-lib.cm is stable]
[library $smlnj/MLRISC/Control.cm is stable]
[library $SMLNJ-MLRISC/Control.cm is stable]
[library $controls-lib.cm(=$SMLNJ-LIB/Controls)/controls-lib.cm is stable]
[library $smlnj/smlnj-lib/controls-lib.cm is stable]
[autoloading done]
val it = () : unit
Hello World!
val it = () : unit
[autoloading]
[autoloading done]