MAIN 未在命令行上由 Factor 执行
我没有看到 Hello World 程序的任何输出。
$ cat hello.factor
USE: io
IN: hello
: hello ( -- ) "Hello World!" print ;
MAIN: hello
$ factor hello.factor
$
(无输出)
$ factor -run=hello
Vocabulary does not exist
name "hello"
$ factor -run=hello hello.factor
$
(无输出)
I'm not seeing any output from my Hello World program.
$ cat hello.factor
USE: io
IN: hello
: hello ( -- ) "Hello World!" print ;
MAIN: hello
$ factor hello.factor
$
(No output)
$ factor -run=hello
Vocabulary does not exist
name "hello"
$ factor -run=hello hello.factor
$
(No output)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MAIN:
当词汇表传递给run
时定义词汇表的入口点,而不一定是像上面那样从命令行“加载”它时。实现此功能的最简单方法是从 UI 侦听器发出"hello" run
。要实际以脚本形式调用
hello
单词,只需在顶层进行调用,如下所示:或者,您可以从命令行加载并运行词汇表
-run=vocab
命令行参数。例如,factor -run=hello
。文档中有更多关于此的信息。尝试在侦听器中运行
"command-line" about
。MAIN:
defines an entry point for a vocabulary when the vocabulary is passed torun
, not necessarily when it is "loaded" from the command line, as you're doing above. The easiest way to make this work is to simply issue"hello" run
from the UI listener.To actually call the
hello
word as a script, simply place a call in the top level, like so:Alternatively, you can load and run the vocabulary from the command line with the
-run=vocab
command line argument. For instance,factor -run=hello
.There is some more information on this in the docs. Try running
"command-line" about
in the listener.Factor 现在为指定一个的命令行脚本执行 MAIN 函数。 (请参阅 GitHub)
Factor now executes a MAIN function for command line scripts that specify one. (See GitHub)