Wilang Documentation1.0.0+4

Cell references#

A math cell can read another cell's value with @cN, where N is the number in that cell's gutter. Every cell gets a number, counting from the top of the note: math cells, Markdown cells, empty cells, and folder headers alike, and a folder's children keep their numbers when the folder is collapsed. There is only that one number — @cN and the gutter always agree.

1: 10
2: 20
3: @c1 + @c2       -> 30
4: sum(@c1:@c3)    -> 60

A Markdown cell, a folder header, and an empty math cell all have a number but no value, so reading one is an error naming that cell. Prose is never skipped over to find the next number, and a range that spans one is an error too — never a zero and never a shorter total.

1: 10
2: Explanation          (Markdown)
3: 20
4: @c1 + @c3       -> 30
5: @c2               -> unavailable: cell 2 has no numeric output
6: sum(@c1:@c3)      -> unavailable: cell 2 has no numeric output

Type @c to complete an earlier cell, hover a reference to see its target, or Ctrl+click (⌘+click on macOS) a reference to jump to it. Inserting, moving, or deleting cells keeps references pointed at the same cells; a deleted target becomes @missing, which never silently rebinds. Turning a target into a Markdown cell keeps its number and makes it unavailable; turning it back into math restores the value.

What a cell contributes#

A reference reads the cell's final executable expression — the last row that runs — not every row, and not the displayed text. For a cell containing:

a = 10
b = 20
a + b

@cN reads 30, not [10, 20, 30]. A trailing semicolon hides output but keeps its value, and comments or blank lines at the end change nothing. To expose several values, end the cell with an explicit collection such as [a, b].

References only reach earlier cells. A reference to the cell itself or to a later cell is an error, as is a range containing the consumer. References work in ordinary formulas (including assignments like total = sum(@c1:@c10)), but not inside deferred function bodies, plot expressions, the REPL, or the global-variable editor — those contexts report that cell references are available only in note math cells.

Ranges and collections#

A range such as @c1:@c3 collects one value per cell in document order, so sum totals every numeric leaf and mean averages every leaf — not one subtotal per cell. A direct reference keeps its shape: @c3 where cell 3 holds [1, 2, 3] is still that vector for arithmetic and indexing. Use flatten(@c1:@c10) for an explicitly flat collection.

Only numbers take part: numeric-looking strings such as "20", booleans, units, plots, functions, empty cells, Markdown cells, folder headers, and failed cells are errors with the originating cell identified — never silent zeros or partial totals.

Stable through edits#

Only range endpoints are identities; membership is the live span between them. A new cell inside the span joins it, moving a member out removes it, and deleting an endpoint breaks the range instead of picking a new one. Duplicating a group of cells repoints internal references at the copies; plain-text paste resolves against the destination note. Saved files, Markdown interchange, and undo/redo all keep the authored @cN source, which is what makes the meaning survive the round trip. Notes written before this convention counted math cells only; they are converted once when opened, and their references keep pointing at the same cells.