on master help sign in
update atoms and strings ref
dd0d1d6Tinnus Napbus
content/docs/hoon/reference/rune/constants.md+101−82
@@ -4,35 +4,33 @@ weight = 1
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/constants/"]
5aliases = ["docs/reference/hoon-expressions/rune/constants/"]
6+++
6+++
7+
7The simplest expressions in every language are constants:
8The simplest expressions in every language are constants:
8−atoms, strings, paths. (Strings and paths aren't all constants per
9+atoms, strings, paths. (Strings and paths aren't all constants per
9se, because they have interpolations.)
10se, because they have interpolations.)
10
11
11−## Expressions
12−
13−### `:_ "Cold Atom"`
12+## "Cold Atom"
14
13
15−`[%rock p=term q=@]`; a constant, cold atom.
14+A constant, cold atom.
16−
17−A cold atom is one whose type is inferred to be of a single atom constant.
18
15
19−##### Produces
16+#### Syntax
20
17
21−A cold (fixed) atom `q` with aura `p`.
18+Any [warm atom](#warm) form, prefixed with `%`.
22
19
23−##### Syntax
20+#### AST
24
21
25−Irregular: any [warm atom](#warm) form, prefixed with `%`.
22+```hoon
23+[%rock p=term q=*]
24+```
26
25
27−Irregular: e.g., `%hi`. Character constraints: `a-z`
26+#### Discussion
28−lowercase to start, `a-z` or `0-9` thereafter, with infix
29−hyphens (`hep`), "kebab-case."
30
27
31−Irregular: `~`.
28+A cold atom is one whose type is inferred to be of a single atom constant.
32
29
33−##### Examples
30+#### Examples
34
31
35−We can see the contrast with warm atoms by using the compiler parser function, `ream`:
32+We can see the contrast with warm atoms by using the compiler parser function,
33+`ream`:
36
34
37```
35```
38> (ream '%hi')
36> (ream '%hi')
@@ -45,20 +43,22 @@ We can see the contrast with warm atoms by using the compiler parser function, `
45[%rock p=%ud q=12]
43[%rock p=%ud q=12]
46```
44```
47
45
46+---
47+
48−### `:_` "Paths"
48+## "Paths"
49
49
50−`[%path p=(list (each @ta hoon))]`: path with interpolation.
50+Path with interpolation.
51
51
52−##### Produces
52+#### Syntax
53
53
54−A null-terminated list of the items in `p`, which are either constant
54+`/this/is/a/path`
55−`@ta` atoms (`knots`), or expressions producing a `knot`.
56
55
57−##### Syntax
56+#### Produces
58
57
59−Irregular: `/this/is/a/path`.
58+A null-terminated list of the items, which are either constant `@ta` atoms
59+(`knots`), or expressions producing a `knot`.
60
60
61−##### Examples
61+#### Examples
62
62
63```
63```
64> `path`/this/is/a/path
64> `path`/this/is/a/path
@@ -74,19 +74,19 @@ Irregular: `/this/is/a/path`.
74~
74~
75```
75```
76
76
77−### `:_` "Strings with Interpolation"
77+---
78
78
79−`[%knit p=(list (each @t hoon))]`: text string with interpolation.
79+## "Strings with Interpolation"
80
80
81−##### Produces
81+Text string with interpolation.
82
82
83−A tape.
83+#### Syntax
84
84
85−##### Syntax
85+A [$tape](/docs/hoon/reference/stdlib/2q#tape)
86
86
87−Irregular: `"abcdefg"`.
87+`"abcdefg"`
88
88
89−Irregular: `"abc{(weld "lmnop" "xyz")}defg"`.
89+`"abc{(weld "lmnop" "xyz")}defg"`
90
90
91```
91```
92> "abcdefg"
92> "abcdefg"
@@ -99,7 +99,17 @@ Irregular: `"abc{(weld "lmnop" "xyz")}defg"`.
99[%knit p=~[97 98 99 100 101 102 103]]
99[%knit p=~[97 98 99 100 101 102 103]]
100```
100```
101
101
102+#### AST
103+
104+```hoon
105+[%knit p=(list woof)]
106+```
107+
108+#### Produces
109+
110+A tape.
111+
102−##### Examples
112+#### Examples
103
113
104String:
114String:
105
115
@@ -122,11 +132,63 @@ String with interpolated prettyprinting:
122"hello, %world."
132"hello, %world."
123```
133```
124
134
135+---
136+
125−### `:_` "Warm Atoms" {#warm}
137+## "Warm Atoms" {#warm}
138+
139+A constant, warm atom.
140+
141+#### Syntax
142+
143+A table of examples:
144+
145+```
146+Aura Meaning Example Literal Syntax
147+-------------------------------------------------------------------------
148+@ empty aura
149+@c Unicode codepoint ~-~45fed
150+@d date
151+ @da absolute date ~2018.5.14..22.31.46..1435
152+ @dr relative date (ie, timespan) ~h5.m30.s12
153+@f Loobean (for compiler, not castable) &
154+@i Internet address
155+ @if IPv4 address .195.198.143.90
156+ @is IPv6 address .0.0.0.0.0.1c.c3c6.8f5a
157+@n nil (for compiler, not castable) ~
158+@p phonemic base (ship name) ~sorreg-namtyv
159+@q phonemic base, unscrambled .~litsyn-polbel
160+@r IEEE-754 floating-point
161+ @rh half precision (16 bits) .~~3.14
162+ @rs single precision (32 bits) .6.022141e23
163+ @rd double precision (64 bits) .~6.02214085774e23
164+ @rq quad precision (128 bits) .~~~6.02214085774e23
165+@s signed integer, sign bit low
166+ @sb signed binary --0b11.1000
167+ @sd signed decimal --1.000.056
168+ @sv signed base32 -0v1df64.49beg
169+ @sw signed base64 --0wbnC.8haTg
170+ @sx signed hexadecimal -0x5f5.e138
171+@t UTF-8 text (cord) 'howdy'
172+ @ta ASCII text (knot) ~.howdy
173+ @tas ASCII text symbol (term) %howdy
174+@u unsigned integer
175+ @ub unsigned binary 0b11.1000
176+ @ud unsigned decimal 1.000.056
177+ @uv unsigned base32 0v1df64.49beg
178+ @uw unsigned base64 0wbnC.8haTg
179+ @ux unsigned hexadecimal 0x5f5.e138
180+```
181+
182+#### AST
126
183
184+```hoon
127−`[%sand p=term q=@]`; a constant, warm atom.
185+[%sand p=term q=*]
186+```
187+
188+#### Discussion
128
189
129−A 'warm' atom is one whose type is inferred to be general, i.e., not just a single atom type.
190+A 'warm' atom is one whose type is inferred to be general, i.e., not just a
191+single atom type.
130
192
131```
193```
132> `@`12
194> `@`12
@@ -136,9 +198,10 @@ A 'warm' atom is one whose type is inferred to be general, i.e., not just a sing
136nest-fail
198nest-fail
137```
199```
138
200
139−##### Produces
201+#### Produces
140
202
141−A warm (variable) atom `q` with aura `p`. Use the Hoon compiler parser function `ream` to take a closer look:
203+A warm (variable) atom `q` with aura `p`. Use the Hoon compiler parser function
204+`ream` to take a closer look:
142
205
143```
206```
144> (ream '12')
207> (ream '12')
@@ -147,47 +210,3 @@ A warm (variable) atom `q` with aura `p`. Use the Hoon compiler parser function
147> (ream '\'Hello!\'')
210> (ream '\'Hello!\'')
148[%sand p=%t q=36.762.444.129.608]
211[%sand p=%t q=36.762.444.129.608]
149```
212```
150−
151−##### Syntax by example
152−
153−Irregular. A table of examples:
154−
155−```
156−@c UTF-32 ~-foobar
157−@da 128-bit absolute date ~2016.4.23..20.09.26..f27b..dead..beef..babe
158− ~2016.4.23
159−@dr 128-bit relative date ~s17 (17 seconds)
160− ~m20 (20 minutes)
161− ~d42 (42 days)
162−@f loobean & (0, yes)
163− | (1, no)
164−@p ~zod (0)
165−@rd 64-bit IEEE float .~3.14 (pi)
166− .~-3.14 (negative pi)
167−@rs 32-bit IEEE float .3.14 (pi)
168− .-3.14 (negative pi)
169−@rq 128-bit IEEE float .~~~3.14 (pi)
170−@rh 16-bit IEEE float .~~3.14 (pi)
171−@sb signed binary --0b10 (2)
172− -0b101 (-5)
173−@sd signed decimal --2 (2)
174− -5 (-5)
175−@sv signed base32 --0v68 (200)
176− -0vfk (-500)
177−@sw signed base64 --0w38 (200)
178− -0w7Q (500)
179−@sx signed hexadecimal --0x2 (2)
180− -0x5 -5
181−@t UTF-8 text (cord) 'foobar'
182−@ta ASCII text (knot) ~.foobar
183−@ub unsigned binary 0b10 (2)
184−@uc bitcoin address 0c1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
185−@ud unsigned decimal 42 (42)
186− 1.420 (1420)
187−@uv unsigned base32 0v3ic5h.6urr6
188−@uw unsigned base64 0wsC5.yrSZC
189−@ux unsigned hexadecimal 0xcafe.babe
190−```
191−
192−The `@uv` characters are `0-9`, `a-v`. The `@uw` characters are
193−`0-9`, `a-z`, `A-Z`, `-` and `~`.