@@ -7,28 +7,56 @@
77
88# `|_ "barcab"`
99
10−`[%brcb p=spec q=(map term hoon)]`: produce a door, a many-armed core
11−with a sample.
10+Produce a *door* (a core with a sample).
1211
13−## Expands to
12+## Syntax
13+
14+Regular:
1415
1516```
16−=| p
17−|% q
18−==
17+|_ a=spec
18+++ name-1 b=hoon
19+++ name-2 c=hoon
20+ ...
21+++ name-n d=hoon
22+--
1923```
2024
21−## Syntax
25+Note: The `++` rune may be replaced with any other rune in the `+` family.
26+
27+AST:
28+
29+```
30+[%brcb p=spec q=alas r=(map term tome)]
31+```
2232
23−Regular: *1-fixed*, then *battery*.
33+## Semantics
34+
35+The product of a `|_` expression is a *door*, a core with one or more arms whose payload includes a sample. That is, a door is a cell of `[battery [sample context]]`, where the `battery` contains one or more arms.
36+
37+`a` defines the door sample type and usually includes a name assignment (e.g., `n=@`). `a` is followed by a series of arm definitions, each of which begins with a rune in the `+` family (most of `++`). There must be at least one arm, but there may be arbitrarily many. Each arm must include a name, which is followed by the expression (`b`, `c`, and `d` above) that defines the arm product.
38+
39+The context of the door is the subject of the `|_` expression.
40+
41+## Expands to
42+
43+```
44+=| a
45+|%
46+++ name-1 b
47+++ name-2 c
48+ ...
49+++ name-n d
50+--
51+```
2452
2553## Discussion
2654
2755A door is the general case of a gate (function). A gate is a
28−door with only one arm, which has the empty name `$`.
56+door with only one arm, which has the name `$`.
2957
3058Calling a door is like calling a gate except the caller also needs
31−to specify the arm to be computed. So, for example, if you have some door `d` which contains some arm `a`, and you want to pass some argument (i.e., input value `arg`, you would call it with `~(a d arg)`.
59+to specify the arm to be computed. So, for example, if you have some door `door` which contains some arm `arm`, and you want to pass some argument (i.e., input value `arg`), you would call it with `~(arm door arg)`.
3260
3361Because gates are also doors, you can call them the same way. To call the gate `foo` as a door, instead of `(foo baz)` we would write `~($ foo baz)`. This
3462is an irregular form for `%~($ foo baz)`, [%~](../../cen/sig).