on master help sign in
Merge pull request #314 from urbit/rmariani-patch-34

Update 3g

commit0e37e66d022f29b859d31abc037eb5ca5a8eaf49 authorJoshua Reagan <joshuareagan@users.noreply.github.com> dateFri 24 Aug 2018, 11:36 (8 years ago) parentc2d68f9e11d7a7
1 file changed+146−134
docs/hoon/library/3g.md+146−134
docs/hoon/library/3g.md+146−134
@@ -6,24 +6,25 @@ navhome: /docs/
66# 3g: molds and mold builders
77### `++coin`
88
9−Noun literal syntax cases
109
11−Noun literal syntax cases: atoms, jammed nouns, and nestable tuples.
12−Parsed and printed using `++so` and `++co` cores.
10+Noun-literal syntax cases
1311
14−Source
15−------
12+Syntax cases for nouns-literal: atoms, jammed nouns, and nestable tuples. Parsed
13+and printed using `++so` and `++co` cores.
1614
17− ++ coin $% {$$ p/dime} ::
18− {$blob p/*} ::
19− {$many p/(list coin)} ::
20− == ::
15+#### Source
2116
22−Examples
23−--------
17+ ++ coin $% [$$ p=dime]
18+ [$blob p=*]
19+ [$many p=(list coin)]
20+ ==
21+
22+***
23+#### Examples
2424
2525 > `coin`(need (slay '~s1'))
2626 [%$ p=[p=~.dr q=18.446.744.073.709.551.616]]
27+
2728 > `coin`(need (slay '0x2b59'))
2829 [%$ p=[p=~.ux q=11.097]]
2930
@@ -34,8 +35,10 @@ Examples
3435
3536 > `@uv`(jam [3 4])
3637 0v2cd1
38+
3739 > (slay '~02cd1')
38− [~ [%blob p=[3 4]]]
40+ [~ u=[%blob p=[3 4]]]
41+
3942 > ~02cd1
4043 [3 4]
4144
@@ -44,27 +47,22 @@ Examples
4447***
4548### `++dime`
4649
47−Odor-atom pair
48−
49−Used in `++coin`. Convenience methods `++scot` and `++scow` (in
50−Section 2eL) print dimes as `++cord` and `++tape`, respectively.
51−`++slat`, `++slav`, and `++slaw` are used to parse atoms of
52−specific odors.
50+Aura-atom pair
5351
54−Source
55−------
52+Used in `++coin`. Convenience methods [`++scot`](../4m.md) and
53+[`++scow`](../4m.md) print dimes as `++cord` and `++tape`, respectively.
54+[`++slat`](../4m.md), [`++slav`](../4m.md), and [`++slaw`](../4m.md) are used
55+to parse atoms of specific auras.
5656
57− ++ dime {p/@ta q/@} ::
57+#### Source
5858
59+ ++ dime [p=@ta q=@]
5960
60−Examples
61−--------
61+#### Examples
6262
6363 > +>:(slay '0x123')
6464 p=[p=~.ux q=291]
6565
66−
67−
6866***
6967### `++edge`
7068
@@ -72,22 +70,23 @@ Parsing location metadata
7270
7371Optional result `p` and parsing continuation `q`.
7472
75−Source
76−------
73+#### Source
7774
78− ++ hair {p/@ud q/@ud} :: parsing trace
75+ ++ hair [p=@ud q=@ud]
7976
8077
81−Examples
82−--------
78+#### Examples
8379
84−See also: Section 2eD, `++rule`
8580
8681 > *edge
8782 [p=[p=0 q=0] q=~]
83+
8884 > (tall:vast [1 1] "a b")
89− [p=[p=1 q=2] q=[~ [p=[%cnzz p=~[%a]] q=[p=[p=1 q=2] q=" b"]]]]
85+ [p=[p=1 q=3] q=[~ u=[p=[%wing p=~[%a]] q=[p=[p=1 q=2] q=" b"]]]]
9086
87+#### Discussion
88+
89+See also: [Section 2e](../2e.md), `++rule`
9190
9291
9392***
@@ -95,60 +94,58 @@ See also: Section 2eD, `++rule`
9594
9695Parsing line and column
9796
98−A pair of two [`@ud`]() used in parsing indicating line and column number.
97+A pair of two `@ud` used in parsing indicating line and column number.
9998
100−Source
101−------
99+#### Source
102100
103− ++ hair {p/@ud q/@ud} :: parsing trace
101+ ++ hair [p=@ud q=@ud]
104102
105103
106−Examples
107−--------
104+#### Examples
108105
109106 > *hair
110107 [p=0 q=0]
111108
112− > `hair`[1 1] :: parsing starts at [1 1] as a convention.
109+ > `hair`[1 1] :: parsing starts at [1 1] as a convention.
113110 [p=1 q=1]
111+
114112 > ((plus ace) [1 1] " --")
115113 [p=[p=1 q=4] q=[~ u=[p=[~~. " "] q=[p=[p=1 q=4] q="--"]]]]
114+
116115 > `hair`p:((plus ace) [1 1] " --")
117116 [p=1 q=4]
118117
119118
120−
121119***
122120### `++like`
123121
124−Mold generator for an edge
122+Generic edge
123+
124+Generates an `++edge` with a parsed result set to a specific type.
125125
126−`++like` generates an `++edge` with a parsed result set to a specific type.
126+#### Source
127127
128−Source
129−------
128+ ++ like |* a=gate
129+ |= b=_`*`[(hair) ~]
130+ :- p=(hair -.b)
131+ ^= q
132+ :- ~
133+ u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]]
130134
131− ++ like |* a/gate :: generic edge
132− |= b/_`*`[(hair) ~] ::
133− :- p=(hair -.b) ::
134− ^= q ::
135− ?@ +.b ~ ::
136− :- ~ ::
137− u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]] ::
138135
136+#### Examples
139137
140−Examples
141−--------
142138 > *(like char)
143139 [p=[p=0 q=0] q=~]
144140
145141 > (ace [1 1] " a")
146− [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]]
142+ [p=[p=1 q=2] q=[~ u=[p=' ' q=[p=[p=1 q=2] q="a"]]]]
143+
147144 > `(like char)`(ace [1 1] " a")
148145 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]]
149− > `(like ,@)`(ace [1 1] " a")
150− [p=[p=1 q=2] q=[~ [p=32 q=[p=[p=1 q=2] q="a"]]]]
151146
147+ > `(like ,@)`(ace [1 1] " a")
148+ [p=[p=1 q=2] q=[~ u=[p=32 q=[p=[p=1 q=2] q="a"]]]]
152149
153150
154151***
@@ -158,63 +155,55 @@ Location, remainder of parsed text
158155
159156Indicates parsing position `p`, and remaining text to be parsed `q`.
160157
161−Source
162−------
158+#### Source
163159
164− ++ nail {p/hair q/tape} :: parsing input
160+ ++ nail [p=hair q=tape]
165161
166162
167−Examples
168−--------
163+#### Examples
169164
170165 > +<:;~(plug cab cab)
171− c=tub=[p=[p=0 q=0] q=""]
172− > :: tub is a ++nail
173−
174−
166+ c=[p=[p=0 q=0] q=""]
175167
176168***
177169### `++path`
178170
179171Filesystem path
180172
181−A `++path` is a list of `++span`s aka `@ta`. Used in
182−`%clay` and `%eyre` extensively.
173+A list of `++knot`s. `++knot` is another name for `@ta`.
183174
184−Source
185−------
175+#### Source
186176
187− ++ path (list knot) :: filesys location
177+ ++ path (list knot)
188178
189179
190−Examples
191−--------
180+#### Examples
192181
193182 > `path`"abc"
194183 /a/b/c
195184
185+#### Discussion
196186
187+Used in `%clay` and `%eyre` extensively.
197188
198189***
199190### `++pint`
200191
201192Parsing range
202193
203−Mostly used for stacktraces. A `++pint` is a pair of
204−`++hair`, indicating from `p` to `q`.
194+A `++pint` is a pair of `++hair`, indicating from `p` to `q`. Mostly used for
195+stack traces.
205196
206−Source
207−------
197+#### Source
208198
209− ++ pint {p/{p/@ q/@} q/{p/@ q/@}} :: line+column range
199+ ++ pint [p=[p=@ q=@] q=[p=@ q=@]]
210200
211201
212−Examples
213−--------
202+#### Examples
203+
204+ > !:(!!) :: !! always produces a crash
205+ /~zod/home/~2014.9.20..01.22.04..52e3/:<[1 4].[1 6]>
214206
215− > !:(!!)
216− ! /~zod/try/~2014.9.20..01.22.04..52e3/:<[1 4].[1 6]>
217− > :: !! always produces a crash
218207 > `pint`[[1 4] [1 6]]
219208 [p=[p=1 q=4] q=[p=1 q=6]]
220209
@@ -225,115 +214,138 @@ Examples
225214
226215Parsing rule
227216
228−`++rule` is an empty parsing rule, but it is used to check
229−that parsing rules match this with `_`.
230−
217+An empty parsing rule, but used to check that parsing rules match this with `_`.
231218
232−Source
233−------
234219
235− ++ rule _|=(nail *edge) :: parsing rule
220+#### Source
236221
222+ ++ rule _|=(nail *edge)
237223
238−Examples
239−--------
240224
241− > *rule
242− [p=[p=0 q=0] q=[~ [p=0 q=[p=[p=0 q=0] q=""]]]]
225+#### Examples
243226
244− > ^+(rule [|=(a=nail [p.a ~])]:|6)
245− <1.dww [tub=[p=[p=@ud q=@ud] q=""] <101.jzo 1.ypj %164>]>
246− > (^+(rule [|=(a=nail [p.a ~ u=['a' a]])]:|6) [1 1] "hi")
247− [p=[p=1 q=1] q=[~ [p=97 q=[p=[p=1 q=1] q="hi"]]]]
248227 > ([|=(a=nail [p.a ~ u=['a' a]])]:|6 [1 1] "hi")
249228 [[p=1 q=1] ~ u=['a' p=[p=1 q=1] q="hi"]]
250229
251230
252−
253231***
254232### `++spot`
255233
256234Stack trace line
257235
258−A `++spot` is what we print after crashing.
259−
260−Source
261−------
236+The stack trace that is printed after crashing.
262237
263− ++ spot {p/path q/pint} :: range in file
238+#### Source
264239
240+ ++ spot [p=path q=pint]
265241
266−Examples
267−--------
242+#### Examples
268243
269− > :into /=main=/bin/fail/hoon '!: !!'
270− + /~zod/main/359/bin/fail/hoon
271− > :fail
272− ! /~zod/main/~2014.9.22..18.40.56..ef04/bin/fail/:<[1 5].[1 7]>
244+ > !: !! :: !! always produces a crash
245+ /~zod/home/~2018.8.8..21.42.40..7852:<[1 5].[1 7]>
273246 ! exit
274247
275248
249+***
250+### `++tone`
251+
252+Nock result, error report
253+
254+Produces either success (`%0`), a block with list of requests blocked on (`%1`),
255+or failure with an error report (`%2`).
256+
257+
258+#### Source
259+
260+ ++ tone $% [$0 p=*] :: success
261+ [$1 p=(list)] :: blocks
262+ [$2 p=(list [@ta *])] :: error report
263+ ==
264+
265+#### Examples
266+
267+ > (mink [[20 21] 0 3] $~)
268+ [%0 p=21]
269+
270+
271+ > (mink [[1 2] !=(!:(+(.)))] ,~)
272+ [ %2
273+ p
274+ ~[
275+ [ ~.spot
276+ [ [ \/72.245.008.048.359.254.300.063.028.130.093.488.830.539.186.242.06\/
277+ 3.318.457.928.725.368.447.417.075.673.617.723.940.025.940.705.343
278+ .057.601.925.133.611.559.292.046.932.324.629.048.702
279+ \/ \/
280+ 1.701.670.760
281+ \/347.698.068.472.453.194.464.038.059.283.550.210.118.689.128.761.6\/
282+ 88.459.326.078
283+ \/ \/
284+ 0
285+ ]
286+ [1 20]
287+ 1
288+ 24
289+ ]
290+ ]
291+ ]
292+
276293
277294***
278295### `++toon`
279296
280−Nock computation result
297+Nock result, stack trace
281298
282−Either success (`%0`), a block with list of requests blocked on (`%1`), or
283−failure with stack trace (`%2`).
299+Produces either success (`%0`), a block with list of requests blocked on (`%1`),
300+or failure with a stack trace (`%2`).
284301
285−Source
286−------
287302
288− ++ toon $% {$0 p/*} :: success
289− {$1 p/(list)} :: blocks
290− {$2 p/(list tank)} :: stack trace
291− == ::
303+#### Source
292304
305+ ++ toon $% [$0 p=*] :: success
306+ [$1 p=(list)] :: blocks
307+ [$2 p=(list tank)] :: stack trace
308+ ==
309+
310+
311+#### Examples
293312
294−Examples
295−--------
296313 > (mock [[20 21] 0 3] $~)
297314 [%0 p=21]
298− > (mock [[0] !=(.^(cy//=main/1))] ,~)
299− [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]]
300− > (path [31.075 1.685.027.454 1.852.399.981 49 0])
301− /cy/~zod/main/1
302315
303316 > (mock [[1 2] !=(!:(+(.)))] ,~)
304317 [%2 p=~[[%leaf p="/~zod/try/~2014.9.23..18.34.32..d3c5/:<[1 20].[1 24]>"]]]
305318
306319
307−
308320***
309321### `++wonk`
310322
311−XX Not a model?
323+Product from edge
312324
313325Pull result out of a `++edge`, or crash if there's no result.
314326
315−Source
316−------
327+#### Source
317328
318− ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq)) ::
329+ ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq))
319330
320−Examples
321−--------
322−
323−See also: [`++edge`]()
331+#### Examples
324332
325333 > (wide:vast [1 1] "(add 2 2)")
326334 [ p=[p=1 q=10]
327335 q
328336 [ ~
329− [ p=[%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]]
337+ u
338+ [ p=[%cnhp p=[%wing p=~[%add]] q=~[[%sand p=%ud q=2] [%sand p=%ud q=2]]]
330339 q=[p=[p=1 q=10] q=""]
331340 ]
332341 ]
333342 ]
343+
334344 > (wonk (wide:vast [1 1] "(add 2 2)"))
335− [%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]]
345+ [%cnhp p=[%wing p=~[%add]] q=~[[%sand p=%ud q=2] [%sand p=%ud q=2]]]
336346
347+#### Discussion
337348
349+See also: `++edge`
338350
339351***