标准 ML / NJ:加载函数文件
Standard ML / NJ: Loading in file of functions
我正在尝试在 SML 文件中编写一堆函数,然后将它们加载到解释器中。我一直在谷歌搜索并发现了这个:
http://www.smlnj.org/doc/interact.html
其中有这一段:
Loading ML source text from a file
The function use: string -> unit interprets its argument as a file name relative to sml's current directory and loads the text from that file as though it had been typed in. This should normally be executed at top level, but the loaded files can also contain calls of use to recursively load other files.
所以我的当前目录中有一个 test.sml 文件。我运行sml
,到目前为止一切都很好。然后我尝试 use test.sml;
并得到:
stdIn:1.6-1.14 Error: unbound structure: test in path test.sml
不确定为什么这不起作用。有什么想法吗?
谢谢,
克莱曼
如您所述,函数 use
的类型为 string -> unit
。这意味着它需要 string
和 returns unit
。当你做 use test.sml
时,你并没有给它一个字符串。你需要做 use "test.sml"
(注意引号)
我正在尝试在 SML 文件中编写一堆函数,然后将它们加载到解释器中。我一直在谷歌搜索并发现了这个:
http://www.smlnj.org/doc/interact.html
其中有这一段:
Loading ML source text from a file
The function use: string -> unit interprets its argument as a file name relative to sml's current directory and loads the text from that file as though it had been typed in. This should normally be executed at top level, but the loaded files can also contain calls of use to recursively load other files.
所以我的当前目录中有一个 test.sml 文件。我运行sml
,到目前为止一切都很好。然后我尝试 use test.sml;
并得到:
stdIn:1.6-1.14 Error: unbound structure: test in path test.sml
不确定为什么这不起作用。有什么想法吗?
谢谢, 克莱曼
如您所述,函数 use
的类型为 string -> unit
。这意味着它需要 string
和 returns unit
。当你做 use test.sml
时,你并没有给它一个字符串。你需要做 use "test.sml"
(注意引号)