on master help sign in
revisions to wut runes
commitfc1a9ce26bc49d069a4ae644afa506c757c4ce19 authorjoshuareagan <joshuareagan@gmail.com> dateWed 10 Oct 2018, 14:00 (8 years ago) parentaddb6f6
12 files changed+71−44
docs/reference/rune/wut/ban.udon+18−4 docs/reference/rune/wut/col.udon+5−10 docs/reference/rune/wut/dot.udon+3−2 docs/reference/rune/wut/hep.udon+8−7 docs/reference/rune/wut/ket.udon+1−1 docs/reference/rune/wut/led.udon+16−2 docs/reference/rune/wut/lus.udon+6−4 docs/reference/rune/wut/pad.udon+1−1 docs/reference/rune/wut/sig.udon+2−4 docs/reference/rune/wut/tis.udon+5−6 docs/reference/rune/wut/vat.udon+5−2 docs/reference/rune/wut/zap.udon+1−1
docs/reference/rune/wut/ban.udon+18−4
@@ -5,9 +5,9 @@
55 ==
66;>
77
8−# `?> "wutgar"`
8+# `?> "wutban"`
99
10−`[%wtgr p=hoon q=hoon]`: positive assertion.
10+`[%wtbn p=hoon q=hoon]`: positive assertion.
1111
1212## Expands to
1313
@@ -19,12 +19,26 @@
1919
2020Regular: *2-fixed*.
2121
22+## Discussion
23+
24+`?>` is used to force a crash when some condition `p` doesn't yield 'yes', `%.y`.
25+
26+It can be used for type inference, with the `?=` rune, to specify the type of a value.
27+
2228## Examples
2329
2430```
25−~zod:dojo> ?>(=(3 3) %foo)
31+> ?>(=(3 3) %foo)
2632%foo
2733
28−~zod:dojo> ?>(=(3 4) %foo)
34+> ?>(=(3 4) %foo)
2935ford: build failed
36+
37+> =a `*`123
38+
39+> `@`a
40+nest-fail
41+
42+> ?>(?=(@ a) `@`a)
43+123
3044```
docs/reference/rune/wut/col.udon+5−10
@@ -14,16 +14,11 @@
1414If `p` produces yes, `%.y`, then `q`. If `p` produces no, `%.n`, then `r`.
1515If `p` is not a boolean, compiler yells at you.
1616
17−The subjects of `q` and `r` are constrained to match any
18−pattern-matching algebra in `p`. The analysis, which is
19−conservative, understands any combination of [`?=` ("wuttis")](../tis/),
20−[`?&` ("wutpad")](../pad/), [`?|` ("wutbar")](../bar/), and
21−[`?!` ("wutzap")](../zap/), and reduces the subject appropriately when
22−compiling.
17+### Type inference
2318
24−If test analysis reveals that either branch is not taken,
25−or if `p` is not a boolean, compilation fails. However,
26−an untaken branch can be indicated with the `%lost` hoon.
19+The subject types of `q` and `r` are constrained to match any pattern-matching algebra in `p`. The analysis, which is conservative, understands any combination of [`?=`](../tis/), [`?&`](../pad/), [`?|`](../bar/), and [`?!`](../zap/), and infers the type of the subject appropriately when compiling.
20+
21+If test analysis reveals that either branch is never taken, or if `p` is not a boolean, compilation fails. An untaken branch is indicated with `mint-lost`.
2722
2823## Syntax
2924
@@ -36,7 +31,7 @@ and includes the expected inference. For instance,
3631if you write `?&(a b)`, `b` is only executed if `a` is
3732positive, and compiled with that assumption.
3833
39−Note also that all other branching hoons reduce to `?:`.
34+Note also that all other branching expressions reduce to `?:`.
4035
4136## Examples
4237
docs/reference/rune/wut/dot.udon+3−2
@@ -21,8 +21,9 @@ Regular: *3-fixed*.
2121
2222## Discussion
2323
24−As usual with inverted forms, use `?.` ("wutdot") when the yes-case
25−expression is much taller and/or wider than the no-case expression.
24+`?.` is just like `?:`, but with its last two subexpressions reversed.
25+
26+As is usual with inverted forms, use `?.` when the yes-case expression is much taller and/or wider than the no-case expression.
2627
2728## Examples
2829
docs/reference/rune/wut/hep.udon+8−7
@@ -7,8 +7,7 @@
77
88# `?- "wuthep"`
99
10−`[%wthp p=wing q=(list (pair model value))]`: switch against a
11−union, with no default.
10+`[%wthp p=wing q=(list (pair spec value))]`: switch against a union, with no default.
1211
1312## Expands to
1413
@@ -39,10 +38,12 @@ Regular: *1-fixed*, then *jogging*.
3938
4039## Discussion
4140
41+The `?-` rune is for a conditional expression in which the type of `p` determines which branch is taken. Usually the type of `p` is a union of other types. There is no default branch.
42+
4243The compiler makes sure that your code neither misses a case of
4344the union, nor includes a double case that isn't there. This is
44−not special handling for `?-` ("wuthep"), just a consequence of the
45−semantics of `?:` ("wutcol"), which `?-` reduces to.
45+not special handling for `?-`, just a consequence of the
46+semantics of `?:`, which `?-` reduces to.
4647
4748A missing case will throw the `mint-lost` error. An extra case
4849will throw `mint-vain`.
@@ -50,10 +51,10 @@ will throw `mint-vain`.
5051## Examples
5152
5253```
53−~zod:dojo> =cor |= vat=?($a $b)
54+~zod:dojo> =cor |= vat=?(%a %b)
5455 ?- vat
55− $a 20
56− $b 42
56+ %a 20
57+ %b 42
5758 ==
5859
5960~zod:dojo> (cor %a)
docs/reference/rune/wut/ket.udon+1−1
@@ -22,7 +22,7 @@ Regular: *3-fixed*.
2222
2323## Discussion
2424
25−Regular form: *3-fixed*
25+The type of the wing, `p`, must not be known to be either an atom or a cell, or else you'll get a `mint-vain` error at compile time. `mint-vain` means that one of the `?^` branches, `q` or `r`, is never taken.
2626
2727## Examples
2828
docs/reference/rune/wut/led.udon+16−2
@@ -19,12 +19,26 @@
1919
2020Regular: *2-fixed*.
2121
22+## Discussion
23+
24+`?<` is used to force a crash when some condition `p` doesn't yield 'no', `%.n`.
25+
26+It can be used for type inference with the `?=` rune, much like the `?>` rune.
27+
2228## Examples
2329
2430```
25−~zod:dojo> ?<(=(3 4) %foo)
31+> ?<(=(3 4) %foo)
2632%foo
2733
28−~zod:dojo> ?<(=(3 3) %foo)
34+> ?<(=(3 3) %foo)
2935ford: build failed
36+
37+> =a `*`[12 14]
38+
39+> `^`a
40+nest-fail
41+
42+> ?<(?=(@ a) `^`a)
43+[12 14]
3044```
docs/reference/rune/wut/lus.udon+6−4
@@ -39,15 +39,17 @@ Regular: *2-fixed*, then *jogging*.
3939
4040## Discussion
4141
42−An extra case will throw `mint-vain`. A lost case defaults.
42+The `?+` rune is for a conditional expression in which the type of `p` determines which branch is taken. Usually the type of `p` is a union of other types. If `p`'s type doesn't match the case for any given branch, the default expression, `q`, is evaluated.
43+
44+If there is a case that is never taken you'll get a `mint-vain` error.
4345
4446## Examples
4547
4648```
47−~zod:dojo> =cor |= vat=?($a $b)
49+~zod:dojo> =cor |= vat=?(%a %b)
4850 ?+ vat 240
49− $a 20
50− $b 42
51+ %a 20
52+ %b 42
5153 ==
5254
5355~zod:dojo> (cor %a)
docs/reference/rune/wut/pad.udon+1−1
@@ -7,7 +7,7 @@
77
88# `?& "wutpad"`
99
10−`[%wtpm p=(list hoon)]`: logical AND.
10+`[%wtpd p=(list hoon)]`: logical AND.
1111
1212## Expands to
1313
docs/reference/rune/wut/sig.udon+2−4
@@ -7,8 +7,7 @@
77
88# `?~ "wutsig"`
99
10−`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing
11−of the subject is null.
10+`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is null.
1211
1312## Expands to
1413
@@ -22,8 +21,7 @@ Regular: *3-fixed*.
2221
2322## Discussion
2423
25−It's bad style to use `?~` to test for any zero atom. Use it
26−only for a true null, `~`.
24+It's bad style to use `?~` to test for any zero atom. Use it only for a true null, `~`.
2725
2826## Examples
2927
docs/reference/rune/wut/tis.udon+5−6
@@ -11,8 +11,7 @@
1111
1212## Produces
1313
14−`%.y` (yes) if the noun at `q` is in the type of `p`;
15−`%.n` (no) otherwise.
14+`%.y` (yes) if the noun at `q` is in the type of `p`; `%.n` (no) otherwise.
1615
1716## Syntax
1817
@@ -20,7 +19,7 @@ Regular: *2-fixed*.
2019
2120## Discussion
2221
23−`?=` ("wuttis") is not as powerful as it might seem. For instance, it
22+`?=` is not as powerful as it might seem. For instance, it
2423can't generate a loop -- you cannot (and should not) use it to
2524test whether a `*` is a `(list @)`. Nor can it validate atomic
2625auras.
@@ -28,11 +27,11 @@ auras.
2827Patterns should be as weak as possible. Unpack one layer of
2928union at a time. Don't confirm things the type system knows.
3029
31−For example, when matching a book containing a page `[%foo p=@
32−q=[@ @]]`, the proper pattern is `[%foo *]`. You have one
30+For example, when matching from a tagged union for the type `[%foo p=@
31+q=[@ @]]`, the appropriate pattern is `[%foo *]`. You have one
3332question, which is whether the head of the noun is `%foo`.
3433
35−A common error is `find.$`, meainng `p` is not a type.
34+A common error is `find.$`, meaning `p` is not a type.
3635
3736## Examples
3837
docs/reference/rune/wut/vat.udon+5−2
@@ -7,8 +7,7 @@
77
88# `?@ "wutvat"`
99
10−`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing
11−of the subject is an atom.
10+`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is an atom.
1211
1312## Expands to
1413
@@ -20,6 +19,10 @@ of the subject is an atom.
2019
2120Regular: *3-fixed*.
2221
22+## Discussion
23+
24+The type of the wing, `p`, must not be known to be either an atom or a cell, or else you'll get a `mint-vain` error at compile time. `mint-vain` means that one of the `?@` branches, `q` or `r`, is never taken.
25+
2326## Examples
2427
2528```
docs/reference/rune/wut/zap.udon+1−1
@@ -15,7 +15,7 @@
1515.=(| p)
1616```
1717
18−Produces the logical "not" of `p`.
18+Produces the logical NOT of `p`.
1919
2020## Syntax
2121