Keywords · ROOT
ROOT
The ROOT is the whole program — the outermost scope, the one thing every other
keyword sits inside. It is not written: there is no ROOT line in source, only the program
file itself. Anything not nested inside another keyword is at the Root.
Format
ROOT has no keyword of its own. It is the top of the tree: the lines with no indentation
are its direct members.
ROOT ::= { MODULE | NATIVE | runStatement }
runStatement ::= CALL | LET | STATE | WITH | COMMENT
MODULE, NATIVE) and the
statements of the run body, in source order.In the canonical form the Root is the
value Code.Language.Program.Structure: three arrays — its modules, its
natives, and its run body.
Usage
The ROOT has no container — it is the program. Everything below is one of the three
kinds it holds.
Modules
A MODULE at the Root opens the outermost
namespace its members are named under.
MODULE App
FUNCTION Text Greeting
= "Hello"
App namespace.Native setup
A NATIVE block at the Root is per-target setup
that runs once as the program starts.
NATIVE js "globalThis.__boot = Date.now()"
The run body
Lines that are neither a module nor native setup make up the run body — the code that
actually executes. A bare CALL is the usual entry
point.
App.Show "ready"
Can Contain
The Root holds three kinds of line, in any order.
Containing a MODULE
A module at the Root, opening a root namespace for the declarations inside it.
MODULE Code
TYPE Value
OPTION Text text
Code.Containing a NATIVE
Per-target setup that runs once as the program starts — the only place native setup lives outside a module.
NATIVE js "console.log('starting')"
Containing a CALL
A function called on its own line: a statement in the run body. This is how a program does anything.
App.Start
Containing a LET
A binding in the run body, computed as the program runs.
LET Text greeting = App.Greeting
LET at the Root, part of the run body.Targets
How the Root renders.
JavaScript
// modules become namespace objects, native setup runs at load,
// and the run body executes as the entry point
globalThis.__boot = Date.now();
App.Show();
JSON
["ROOT",
[ ["MODULE", "App", [], [], [], [], [], []] ],
[ ["NATIVE", "js", "globalThis.__boot = Date.now()"] ],
[ ["CALL", "App.Show", [], []] ]
]
Related
The Root holds MODULE declarations,
NATIVE setup, and a run body whose entry point
is a CALL. Its canonical shape is
Code.Language.Program.Structure.
Back to the language.