Answer architecture round 3, stability round 1 and product-owner round 1: CalcName and proven.OfCalc for one meaning per name, a lazy load placed where its lookup found it, DataType's constants typed under it, and cover printing the module's total

This commit is contained in:
2026-10-05 15:53:56 +02:00
committed by Lillem4n
parent 679bd43c7c
commit 4f484cd780
11 changed files with 34 additions and 33 deletions
+4 -4
View File
@@ -43,9 +43,9 @@ type builtin struct {
prints datatype.DataType
}
// Calc is the name of the builtin whose operands the caller checks and proves, as nodes only
// it holds.
const Calc = "calc"
// CalcName is the builtin whose operands the engine checks and proves, since only the engine
// holds their nodes.
const CalcName = "calc"
// rng is the randomness a builtin sample draws from, which *drawstate.State satisfies.
type rng interface {
@@ -115,7 +115,7 @@ func numberCalls(text bool) string {
}
}
slices.Sort(calls)
return strings.Join(calls, ", ") + " or {calc()}"
return strings.Join(calls, ", ") + " or {" + CalcName + "()}"
}
func plural(n int) string {
+3 -3
View File
@@ -64,9 +64,9 @@ var builtins = withTransforms(map[string]builtin{
cc := a[0]
return func(s *drawstate.State, _ string, _ []string) string { return iban(s, cc) }
}},
"date": {arity: -1, checkArgs: dateArgs, prep: datePrep},
"time": {arity: -1, checkArgs: timeArg, prep: timePrep},
Calc: {arity: -1, checkArgs: checkCalc, prep: calcPrep, operands: calcOperands, noRefOperands: true},
"date": {arity: -1, checkArgs: dateArgs, prep: datePrep},
"time": {arity: -1, checkArgs: timeArg, prep: timePrep},
CalcName: {arity: -1, checkArgs: checkCalc, prep: calcPrep, operands: calcOperands, noRefOperands: true},
// seq is the one stateful builtin: a per-generator counter from 1, advancing on
// each call. An optional name selects an independent counter; no name uses the
// default one. Deterministic by construction, so seeded output stays stable.