首页 文章

增加SML / NJ中的打印深度

提问于
浏览
15

我试图让SML / NJ在顶层打印出一个结果,而不是在任何地方放置#符号 .

根据一些旧的文档(以及2001年新闻组的帖子),应该可以使用 Compiler.Control.Print.printDepth

但是,在SML / NJ版本110.7上,这只是一个错误:

- Compiler.Control.Print.printDepth := 100;
stdIn:1.1-30.8 Error: unbound structure: Control in path Compiler.Control.Print.printDepth

1 回答

  • 16

    你将来可能不会更精确 . 例如,您可以提供一些示例输出以及指向上述位置的链接 .

    如果我理解你的问题是正确的,那么下面的最后一行是你的问题? (代码片段

    - datatype tree = leaf | node of int * tree * tree;
    datatype tree = leaf | node of int * tree * tree 
    
    - val t = node (1, node (2, node (3, leaf, leaf), leaf), leaf);
    val t = node (1,node (2,node #,leaf),leaf) : tree
    

    那么Control.Print结构就是你要找的 . 所以只需删除 Compiler 部分即可使用

    Control.Print.printDepth := 100;
    

    请注意,这是特定于SML / NJ的,而不是ml-yacc .

相关问题