on 3fee830 help sign in
90 lines 1.6 kB history raw
1---
2sort: 6
3---
5# Cores (`|` runes)
7Core twigs are flow twigs. The compiler essentially pins a Nock
8formula, or battery of formulas, to the subject.
10All `|` twigs are macros around `$core`. (See the `$core`
11section in [`span`](../span) above.) `$core` uses the subject as
12the payload of a battery, whose arms are compiled with the core
13itself as the subject.
15## Regular forms
17The rune prefix is `|`. Suffixes: `%` for `:core`, `=` for
18`:gate`, `-` for `:loop`, `.` for `:trap`, `_` for `:door`.
20### `:core`, `|%`, "barcen", `{$core p/(map term twig)}`
22Syntax: *battery*
24The product: a core with battery `p`. Payload is the subject.
26### `:gate`, `|=`, "bartis", `{$gate p/moss q/twig}
28Syntax: *2-fixed*.
30Expands to:
32```
33:new p
34:core
35++ $
36 q
37--
38```
40A `$gate` produces a function from `p` to `q`. `p` is the
41*sample*, or argument. The core has one formula, named `$` (the
42empty name). The payload is of the form `{sample context}`,
43where `context` is the subject of the gate.
45### `:loop`, `|-`, "barhep", `{$loop p/twig}`
47Syntax: *1-fixed*.
49Expands to:
51```
52 :rap $
53 :core
54 ++ $
55 p
56 --
57```
59A `$loop` makes a core with one anonymous arm `p`, then takes
60that arm.
62### `:trap`, `|.`, "bardot", `{$trap p/twig}`
64Syntax: *1-fixed*.
66Expands to:
68```
69 :core
70 ++ $ p
71 --
72```
74A `$trap` is a deferred value.
76### `:door`, `|_`, "barcab", `{$door p/moss q/(map term twig)}`
78Syntax: *1-fixed*, then *battery*.
80Expands to:
82```
83 :new p
84 :core
85 q
86 ==
87```
89A `gate` is a function; a `door` is the general case of a
90function. Wut? We'll look at this again from the caller's side.