如何禁用SMLNJ警告? [英] How to disable SMLNJ warnings?

查看:226
本文介绍了如何禁用SMLNJ警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写命令行脚本,但SML的警告模糊了界面。

I'm trying to write command line scripts, but SML's warnings obfuscate the interface.

文档说:

Compiler.Control.printWarnings := false;



But SMLNJ has since renamed these to:

Control.printWarnings := false;

其实会产生更多的打印输出。

Which actually produces even more printouts.

示例:

$ 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]


推荐答案

首先,你需要修复这些警告,而不是忽略它们。任何其他的只是丑陋的习惯!

First of all you would want to fix those warnings, instead of just ignoring them. Anything else is just ugly habit!

print "Hello World!\n";
val _ = OS.Process.exit(OS.Process.success);

此外,据我所知:没有办法摆脱自动加载邮件sml / nj。你可以试试另一个翻译。 Poly / ml没有多说,但我似乎找不到一个方法来启动它的文件。 Mosml也不聊天太多,在这里你可以在一个文件(甚至一个.mlb文件,只要我被告知 - 它是无记录的)。

Besides that, as far as I know: There is no way of getting rid of the autoloading messages in sml/nj. You could try another interpreter. Poly/ml doesn't say much, however I can't seem to find a way to start it on a file. Mosml doesn't chat much either, and here you can start it on a file (even an .mlb file as far as I have been told -- it is undocumented).

另一种方法是编译你的文件,然后脚本的目的就会消失。

Another way would be to compile your files, however then the purpose of scripting kind of fades away.

你有一个sml没有是工作的正确工具。

You have stumpled upon one of the cases where sml aren't the right tool for the job.

更新。

我发现你可以通过在编译管理器的控制器中将verbose设置为off来实现:

I found out that you can actually get some of the way by setting verbose to off in the compilation manager's controller:

;#set CM.Control.verbose false;

这样可以摆脱大部分,但是它仍然会打印一些自动加载消息,因为它必须加载CM.Control结构。它只是关闭后。然而,文档还建议您可以设置环境变量CM_VERBOSE

This gets rid of most, however it still prints some auto loading messages, as it has to load the CM.Control structure. And it only shuts up afterwards. The documentation however also suggests that you can set the environment variable CM_VERBOSE

CM_VERBOSE=false sml foo.sml

这使它几乎安静。使用此来源

which makes it almost quiet. Using this source

val _ = print "Hello World!\n";
val _ = OS.Process.exit(OS.Process.success);

生成以下输出:

$ CM_VERBOSE=false sml foo.sml 
Standard ML of New Jersey v110.72 built: Wed May 12 15:29:00 2010] 
[opening foo.sml] 
Hello World!

注意 val _ = ... 每次不要写 val it =():unit

这篇关于如何禁用SMLNJ警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆