【发布时间】:2012-10-11 15:48:33
【问题描述】:
我正在编写一个应用程序,我想在数据类型声明的 withtype 子句中定义许多类型。下面的代码 sn -p 演示一下:
datatype ta = A
withtype tb = int
and tc = tb
mlton 无法编译此代码,尽管 smlnj 成功。
$ mlton -stop o test.sml
Error: test.sml 3.15.
Undefined type tb.
compilation aborted: parseAndElaborate reported errors
我正在使用 mlton-20100608 和 smlnj-110.71。
这是 mlton 中的错误吗?
如果没有这种声明,我不知道该怎么做:一组相互递归的数据类型和类型。
这个想法来自 Andrew Appel 在他的书 Modern Compiler Implementation in ML,第 98 页,文件 absyn.sml 中为 Tiger 语言提出的抽象语法树类型
【问题讨论】: