R2 · 30 keywords

R2 · Keywords and their lowerings

Every keyword by the slot it occupies, and for the sugar forms, what each one rewrites to. The kernel-and-sugar split is one of Jock’s four design principles, so the lowering is the part of a keyword worth knowing second.

No railroad diagrams, and that is a ruling

OUTLINE.md R2 asks for railroad diagrams. A railroad diagram is a rendering of a grammar, and the agent reference already rules on writing one:

Jock’s parser is recursive descent (parse.hoon); no grammar artifact exists to project from, so a written-out grammar would be a second author of the syntax rather than a rendering of it.

That ruling binds this page. It also says what would lift it — a formal grammar is expressible, and should arrive with the corpus as its acceptance suite, every source-bearing %pos vector parsing and every %parse and %lex refusal failing to, so that it is a lane and not a claim. Until then: the slots below, and the lowerings, which are normatively stated.

The keywords, by slot

Declaration (14)

keywordstated at
aliasL-61, L-66, L-22, L-81, L-45
classL-61, L-22, L-146, L-45
enumL-61, L-69, L-22, L-149, L-170, L-45
forL-61
funcL-185, L-61, L-17, L-20, L-87, L-135, L-136, L-137, L-139, L-140, L-143
implL-61, L-20, L-45
importL-185, L-61
isL-61, L-69
lambdaL-61
letL-185, L-61, L-20, L-129, L-130, L-131, L-134, L-171
privateL-61, L-37, L-17, L-25
structL-61, L-45
traitL-61, L-22, L-45
varL-61, L-129, L-130, L-131, L-132, L-134

Control (10)

keywordstated at
assertL-185, L-61
crashL-61, L-178, L-182
deferL-61, L-188
elseL-61
evalL-61, L-13, L-129, L-188
ifL-185, L-61
loopL-185, L-61, L-87, L-140
matchL-185, L-61, L-84, L-101, L-126, L-148, L-150, L-151, L-173
printL-61, L-76, L-35
recurL-61, L-140, L-152

Operator (6)

keywordstated at
andL-61, L-107, L-173, L-178
asL-61, L-24, L-12, L-107, L-120
inL-61, L-73, L-107, L-108, L-115, L-173, L-188
notL-61, L-107, L-173, L-178
orL-61, L-107, L-173, L-178
xorL-61, L-107, L-173, L-178

The sugar rewrite index

language.md §8, projected. Each sugar form is normatively stated once, at the id named in the third column, and lib/sugar.hoon must match it. A form not in this table is kernel: it has no rewrite because it is what the rewrites land on.

SugarRewriteStated at
assert c; eif c { e } else { crash }L-61 (the inventory)
a ?? bmatch on unitL-126
binary operatorsstdlib callsL-38 to L-45
=== / !==kernel %sameL-106
and / ornested %if (short-circuit)L-61
xor / not%if and stdlib rewritesL-61
%dot (postfix ., non-limb receiver)irrefutable match binding the receiver onceL-113
index family.at(i) / .slice(a, b) / .put(i, v)L-46 to L-51
larkhead/tail by axisL-100 to L-105
Unicode glyph aliases∈→in, ×→*, ÷→/L-115
print e; k%slog dynamic hintL-33 to L-37
string interpolation.show() per headL-26 to L-32
collection literalsconstructor calls / raw nounsL-79