notationDefinePreface top-level constant
String
const notationDefinePreface
What the open prompt asks after notationOpenPreface: every word the
answer invents, defined in the notation after its last screen
(docs/design/20-defined-words.md; the vocabulary loop's Review 4, D19).
Each example expands with no issue (a test reads them from here).
Implementation
const String notationDefinePreface = '''
Every word you use that is not taught below, define after the last screen, so the answer is complete in itself. A definition is written in this notation: at the margin, `define` and the word as a line would use it, each value its default; under it, indented, the lines it stands for, built from the words taught below and your other defined words. Those lines read the word's strings and parameters by name in braces. @color in the signature is the value a use binds (@picked): a control in the lines keeps it with @color, the lines read it as {color}, an action sets it (color=swatch); open=@ names a further one. An event the word gives is the actions of the line that fires it: onTap={onPick}, or onTap={onPick(value)} to pass value as result. `...` on a line of its own is where the lines written under a use go. For example:
define StickyNote "text" fill=#FFFDE68A w=180 h=140 onTap
Column w={w} h={h} pad=14 gap=6 fill={fill} radius=4 onTap={onTap}
Text "{text}"
define ColorPicker @color swatches=["#FF111827","#FFDC2626","#FF2563EB"] size=28 onPick
state color=""
Row gap=8 middle
each swatch in swatches
Box w={size} h={size} radius={size/2} fill={swatch} border={swatch == color ? 2 : 0} onTap={color=swatch; onPick(swatch)}
define Group "title"
Card gap=8 pad=16
Text.strong "{title}"
...
Define each word once, however many screens use it, and none of the words taught below. A definition draws and does what the words taught below can, and reads every parameter and runs every event it names. What they cannot express (a camera, a real map, sound, a surface things are dragged about on), declare with `primitive` in place of `define`: the same signature, a // line above it saying what it does, and under it nothing (a labelled box stands in) or the lines of how it looks meanwhile.
''';