相关疑难解决方法(0)

仅使用SML/NJ打印打印输出

我正在尝试使用SML/NJ,我用它sml < source.sml来运行代码,但它打印出太多的信息.

例如,这是source.sml:

fun fac 0 = 1
  | fac n = n * fac (n - 1)
val r = fac 10 ;
print(Int.toString(r));
Run Code Online (Sandbox Code Playgroud)

这是输出:

Standard ML of New Jersey v110.77 [built: Tue Mar 10 07:03:24 2015]
- val fac = fn : int -> int
val r = 3628800 : int
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[autoloading done]
3628800val it = () : unit
Run Code Online (Sandbox Code Playgroud)

来自标准ML中的抑制"val it"输出,如何禁用SMLNJ警告?,并且SMLNJ想要从每个print语句执行中删除"val it =():unit" …

ml sml smlnj

9
推荐指数
1
解决办法
782
查看次数

如何禁用SMLNJ警告?

我正在尝试编写命令行脚本,但SML的警告会混淆接口.

文档说使用:

Compiler.Control.printWarnings := false;
Run Code Online (Sandbox Code Playgroud)

但是SMLNJ已将这些重命名为:

Control.printWarnings := false;
Run Code Online (Sandbox Code Playgroud)

这实际上产生了更多的打印输出.

例:

$ 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,...)
Run Code Online (Sandbox Code Playgroud)

与:

$ cat hello.sml
Control.printWarnings := false;
print "Hello World!\n";
OS.Process.exit(OS.Process.success);
$ sml hello.sml …
Run Code Online (Sandbox Code Playgroud)

command-line interface sml smlnj

5
推荐指数
1
解决办法
832
查看次数

标签 统计

sml ×2

smlnj ×2

command-line ×1

interface ×1

ml ×1