on 01ac191 help sign in
53 lines 1.7 kB history raw
1---
2sort: 6
3next: true
4title: Expressions
5---
7# Expressions
9A Hoon expression is called a `twig`. A `twig` is an AST node:
10the noun that the Hoon compiler makes when it parses a source
11expression.
13The definition of `twig` is the definition of Hoon. So let's
14define the syntax and semantics of Hoon, a twig at a time. But
15first, basic twig anatomy.
17## Twig anatomy and jargon
19A twig is a tagged union (`book`) with the form `{stem bulb}`,
20where the `stem` is an atomic symbol. The bulb for each stem has
21its own type, which varies by stem. (Compare with Lisp, where
22every AST node is a tag and a list of child nodes.)
24There are no user-level macros. All stems are built into Hoon.
25Most stems are implemented as internal macros, however.
27The bulb is usually a tuple, sometimes a list or map. An element
28of this structure is a *subexpression*.
30Usually a subexpression is itself a `twig`; sometimes it's an
31`@tas` (symbol) or a `wing` (reference path).
33## Moss versus seed
35Solely for clarity, we use the type alias `moss` for twigs whose
36product is used as a mold. A `moss` is just a twig, both in
37syntax and semantics; again, the difference is how we use it.
39Twigs are described as *mossy* (or *moldy*) and *seedy*; an
40example of X is the seedy form of X, a mold producing X is its
41mossy form.
43For instance, `[%foo %bar]` is seedy: a twig producing the noun
44`[7.303.014 7.496.034]`. `{$foo $bar}` is mossy: a twig
45producing a function whose product is always `[7.303.014
467.496.034]`.
48## Twig categories
50Fortunately, the twigs fit neatly into clear categories which
51match their rune prefix. Read forward by category:
53<div><list/></div>