MAIN: - Factor Documentation (original) (raw)

MAIN:
Factor handbook » The language » Vocabulary loader

Prev: reload ( name -- )
Next: run ( vocab -- )

Vocabulary
syntax

Syntax

MAIN: word

Inputs
None

Outputs
None

Word description
Defines the main entry point for the current vocabulary and source file. This word will be executed when this vocabulary is passed to run or the source file is run as a script.

If a quotation is passed instead of a word, then it will be run as the main entry point, in the same way.

Definition

USING: accessors effects kernel namespaces parser source-files
vocabs.parser words ;

IN: syntax

SYNTAX: MAIN:
scan-word dup \ [ = [
drop
"( main )" dup parse-quotation ( -- )
define-declared
] when dup ( -- ) check-stack-effect
[ current-vocab main<< ]
[ current-source-file get [ main<< ] [ drop ] if* ] bi ;