Name renderScope.groupHold for what it returns, correct pathDraw's pins comment, and drop the done round item

This commit is contained in:
2026-09-28 23:18:25 +02:00
committed by Lillem4n
parent 194f194f81
commit 54d933ecc2
8 changed files with 16 additions and 18 deletions
+1 -1
View File
@@ -312,7 +312,7 @@ file the stem of the units it holds.
Two declarations of any kind — function, method, field, type — share a name only where
one definition covers both: the same kind of value, counted or addressed the same way, so
a reader landing on the wrong one concludes nothing false. `Fake` on each template kind
renders one value from what it is called on; `renderScope.hold` returns the `*hold` it
renders one value from what it is called on; `renderScope.groupHold` returns the `*groupHold` it
names. A bare function never shares a name with a method: a search for the name returns
both, and a call site shows no receiver to tell them apart. `TestNoFunctionSpellsAMethod`
holds that, and review judges the rest. Serves goal 2: names that tell the truth, and reaching
+3 -3
View File
@@ -133,8 +133,8 @@ func renderRoot(s *session, t *template) {
for r := 0; r < t.table.rowCount(); r++ {
var set holdSet
sc := renderScope{set: &set}
sc.hold().pins.pin(t.table, r)
render(s, t.table.pinnedRow, sc.at(t.table.pinnedRow, &sc.hold().pins))
sc.groupHold().pins.pin(t.table, r)
render(s, t.table.pinnedRow, sc.at(t.table.pinnedRow, &sc.groupHold().pins))
}
case t.repeat > 1:
expand(s, t, sc)
@@ -147,7 +147,7 @@ func renderRecordRoot(s *session, t *template, columns []Column) {
var set holdSet
sc := renderScope{set: &set}
if t.table != nil {
t.table.drawIn(s, &sc.hold().pins)
t.table.drawIn(s, &sc.groupHold().pins)
}
renderRecord(s, t, columns, sc)
}
+1 -1
View File
@@ -45,7 +45,7 @@ func readField(s *session, t *template, held *hold, sc renderScope, a arm) readV
}
w := pathDraw{s: s, held: held, a: &a}
if isRef(a.key) && len(a.tail) > 0 {
group := sc.hold()
group := sc.groupHold()
w.held, w.pins = &group.hold, &group.pins
}
if r, done := w.held.value[a.path]; done {
+4 -3
View File
@@ -12,8 +12,9 @@ type holdSet struct {
}
// renderScope is where a render reads its reference paths: a hold set, in the draw group of the
// template rendering; and row, the row of the table rendering, which its columns read. It passes by value, and what is read from it reaches a map key, an interface or
// a func value only as a copy; else sc, and with it every render's hold set, moves to the heap.
// template rendering; and row, the row of the table rendering, which its columns read. It passes
// by value, and what is read from it reaches a map key, an interface or a func value only as a
// copy; else sc, and with it every render's hold set, moves to the heap.
type renderScope struct {
set *holdSet
group string
@@ -67,7 +68,7 @@ func (sc renderScope) rowOf(t *table) int {
return sc.row.row
}
func (sc renderScope) hold() *groupHold {
func (sc renderScope) groupHold() *groupHold {
if sc.group == "" {
return &sc.set.unnamed
}
+3 -3
View File
@@ -332,9 +332,9 @@ func (w *pathProbe) readRow(t *table, r tableRoute) error {
return nil
}
// pathDraw draws the rows and variants a proved path reads, pinning the rows in pins, which
// only a path from a reference needs: a table is a category. For a held read, held keeps the
// variant drawn at each level of a, so paths sharing a prefix share it.
// pathDraw draws the rows and variants a proved path reads, pinning the rows in pins; pins is nil
// for a sibling path, which never crosses a table, since a table is only a category. For a held
// read, held keeps the variant drawn at each level of a, so paths sharing a prefix share it.
type pathDraw struct {
s *session
pins *pinSet
+2 -2
View File
@@ -159,7 +159,7 @@ func tableRecord(s *session, t *table, tail []string, sc renderScope) (node, err
}
switch n := n.(type) {
case *table:
n.drawIn(s, &sc.hold().pins)
n.drawIn(s, &sc.groupHold().pins)
return n, nil
case *tableRow:
return n.t, nil
@@ -264,7 +264,7 @@ func recordOf(n node) (*template, []Column, error) {
func renderRecord(s *session, t *template, columns []Column, sc renderScope) *Record {
sc = sc.in(t)
if t.table != nil {
sc = sc.at(t.table.pinnedRow, &sc.hold().pins)
sc = sc.at(t.table.pinnedRow, &sc.groupHold().pins)
}
r := &Record{columns: append([]Column(nil), columns...)}
for i := range r.columns {
+2 -2
View File
@@ -33,7 +33,7 @@ func (f *Generator) Fake(path string) (string, error) {
if _, ok := n.(*folder); ok {
return "", fmt.Errorf("fejkdata: %s names a folder, not a value", path)
}
return render(f.rand, n, sc.at(n, &sc.hold().pins)), nil
return render(f.rand, n, sc.at(n, &sc.groupHold().pins)), nil
}
// descend walks a caller's path to the node it names, pinning in sc the rows it
@@ -43,7 +43,7 @@ func descend(s *session, root node, segments []string, sc renderScope) (node, er
if _, err := (&pathProbe{drawn: map[*table]bool{}}).walk(root, segments); err != nil {
return nil, err
}
return drawPath(root, segments, "", &pathDraw{s: s, pins: &sc.hold().pins}), nil
return drawPath(root, segments, "", &pathDraw{s: s, pins: &sc.groupHold().pins}), nil
}
// render evaluates a compiled node to a string. compile validates every node up
-3
View File
@@ -23,9 +23,6 @@ Shape 5.8, Self-sufficiency 5.7), every seat capped by Locality, all nine naming
This round, in order:
- Split `hold`'s two lifetimes, the expansion's sibling hold and the render's group
hold, into two types, and stop `readField` rewriting `sc.pins`: which pins a column
reads depends on which distant caller last overrode them, the cost seven seats named.
- Return each phase's output from compile, link and format compile, not fill
`template`'s 25 fields in place from four files: five seats had to know which phase a
function runs in to know which fields are valid yet.