开发者

MAIN not executed by Factor on command line

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
$
开发者_如何学Go

(No output)

$ factor -run=hello
Vocabulary does not exist
name "hello"

$ factor -run=hello hello.factor 
$

(No output)


MAIN: defines an entry point for a vocabulary when the vocabulary is passed to run, 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:

USE: io
IN: hello

: hello ( -- ) "Hello World!" print ;

! This is the important part
hello

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 now executes a MAIN function for command line scripts that specify one. (See GitHub)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜