@@ -6,122 +6,10 @@ next: true
66# Atoms and strings
77
88The simplest expressions in every language are constants:
9−atoms and strings. This section
9+atoms, strings, paths. (Strings aren't all constants per
10+se, because they have interpolations.)
1011
11−Some of these constructs aren't quite constants, li
12−
1312## Stems
1413
15−(Some of the "constant" syntax below can interpolate dynamic
16−twigs. When it does, it obviously isn't constant at all.)
14+<list dataPreview="true" className="runes"></list>
1715
18−## Auras
19−
20−Recall the `$atom` span, `{$atom p/aura q/(unit @)}`.
21−
22−Each atom constant syntax implies an `aura`, which is just a
23−textual symbol. The aura is used indiscriminately to convey
24−physical units, semantic interpretations, parsing syntax, and/or
25−printing syntax. It's soft type and can be manually overridden.
26−
27−To write an aura, we generally borrow the atomic mold syntax,
28−such as `@ud` for the unsigned decimal.
29−We write an aura
30−
31−in its irregular mold syntax, such as
32−`@ud`. The syntax for the
33−
34−## Twigs
35−
36−```
37−|%
38−++ twig
39− {$rock p/@tas q/@}
40− {$sand p/@tas q/@}
41− {$knit p/(list $@(@ {$~ p/seed}))}
42− {$path p/(list (each @tas seed))
43−--
44−```
45−
46−## Syntax
47−
48−All Hoon constants are irregular; they have no rune form. The
49−stems described below are `$rock` (cold / constant), `$sand`
50−(warm / open), `$knit` (iterative string), and `$path` (Unix
51−style path).
52−
53−### Atoms
54−
55−Recall the `$atom` span, `{$atom p/aura q/(unit @)}`.
56−
57−Each atom constant syntax implies an aura. Note that the aura is
58−used indiscriminately to convey physical units, semantic
59−interpretations, parsing syntax, and/or printing syntax.
60−
61−### Hardcoded auras
62−
63−### Cold or warm, single or arbitrary
64−
65−A span is a set of nouns; an `$atom` span contains either one
66−atom (*cold*) or all atoms (a *warm*).
67−
68−In general, the `%` prefix is added to indicate coldness. `42`
69−is warm and `%42` is cold. `@tas` symbols (which start with `%`
70−already, see below) are always cold.
71−
72−### Unsigned integer: `@ud`, `@ux`, `@uw`.
73−
74−Unsigned integers are broken into groups of 3 for decimals, and 4
75−for non-decimals, separated German style by `.`; `420` plus `999`
76−is `1.419`, a `@ud`.
77−
78−A hex (`@ux`) favorite is `0xcafe.babe`.
79−
80−`0w` is base64: `0-9`, `a-z` + 10, `A-Z` + 36, `-` and `~`. For
81−giant numbers, you can put whitespace/newlines after the `.`.
82−
83−### Boolean and null: `@f`, `@n`.
84−
85−Booleans in Hoon (`@f`) are `&` for yes (`@f`) and `|` for no.
86−Remember that `&` is `0` and `|` is `1` (which is why we say
87−"yes" and "no" rather than "true" and "false").
88−
89−Nil (aura `@n`) is `~` (with the value `0`).
90−
91−### Atomic string
92−
93−`'text'` in single quotes, `@t`, is a UTF-8 string LSB first.
94−
95−`%symbol`, `@tas`, containing only `a-z`, `0-9` and `-`, starting
96−with `a-z`, and ending with `a-z0-9`, is a valid symbolic name.
97−
98−`%$` is an empty `@tas`, ie, `0` with span `@tas`.
99−
100−### Signed integer: `@sd`
101−
102−Signed integers (`@sd`) are encoded with sign bit *low*. This
103−means we need a special syntax for positive signed integers,
104−since their atomic value can't be their unsigned value. For
105−example, `-3` is the atom `7`, whereas `--3` encodes to `6`.
106−
107−### Iterative string
108−
109−Hoon also has list-shaped strings (less compact, more editable).
110−Use double quotes: `"hello, world"`. The mold is `tape` or
111−`(list char)`, where `char` is a UTF-8 byte.
112−
113−Within a quoted string, interpolate with `{}`: `"hello, {(weld
114−"wo" "rld")}"`. It's also worth noting that `<`, `gar`, and `>`,
115−`gal` (angle brackets) stringify any twig: `"hello, {<mul 6
116−7>}"`. (Obviously, an interpolated string is not a constant.)
117−
118−### Path
119−
120−The path `/foo/bar/baz` is the constant `[%foo %bar %baz ~]`.
121−A path can be dynamically interpolated with `[]`:
122−
123−```
124−/foo/[:(if & %bar %rab)]/baz`
125−```
126−
127−equals `/foo/bar/baz`.