diff --git a/node.go b/node.go index 76ddbbd..a0c4791 100644 --- a/node.go +++ b/node.go @@ -257,11 +257,9 @@ func weightOf(raw any) (float64, error) { // separates the segments of a path, '|' the arms of a token, '(' opens a function // call and '}' ends the token. A name carrying one is reachable by no format, so it // is rejected where it is authored rather than at the token that cannot reach it. -// ')' is absent deliberately — it is spellable on its own, so it stays legal. const reservedInName = ".|(}" -// reservedList is reservedInName spelled out for an error message, so the two -// cannot drift apart. +// reservedList spells reservedInName for an error message, so the two cannot drift. var reservedList = strings.Join(strings.Split(reservedInName, ""), " ") // checkName rejects a name the dot path and {token} grammars cannot spell. Both a diff --git a/render.go b/render.go index 865d0ae..d8e6c91 100644 --- a/render.go +++ b/render.go @@ -138,8 +138,8 @@ func expand(s *session, t *template) string { var b strings.Builder b.Grow(t.grow) // One draw per held name, for this expansion only: a nested template and each - // repeat iteration get their own, since each is its own expansion. held stays a - // local: nothing hands it to a builtin, so it and its maps never leave the stack. + // repeat iteration get their own, since each is its own expansion. held reaches + // no further than readField, which keeps it and its maps on the stack. var held *draws if len(t.held) > 0 { held = &draws{ @@ -157,8 +157,7 @@ func expand(s *session, t *template) string { case 'f': b.WriteString(readField(s, t, held, o.arms[s.IntN(len(o.arms))])) case 'b': - // A calc's operands are read here, in the order its expression first - // names them, so the value it computes is the value the format showed. + // Read in the order calcVars fixed, which is what op.operands holds. var operands []string if len(o.operands) > 0 { operands = make([]string, len(o.operands)) diff --git a/template.go b/template.go index 3c4b9a1..cf1f764 100644 --- a/template.go +++ b/template.go @@ -317,9 +317,8 @@ type op struct { r rune // kind 'c' arms []arm // kind 'f': the '|' alternatives, split into key and path once call callFn - // operands names the sibling fields a {calc()} reads, in the order its - // expression first names them. expand reads them before the call, so the - // evaluator never touches the node tree. nil for every other builtin. + // operands names the sibling fields a {calc()} reads, in the order calcVars + // fixed; expand reads them before the call. nil for every other builtin. operands []string }