Documentation
¶
Overview ¶
Package scriptsum is the sum builtin a managed script is given.
It is separate from the engine for the reason internal/scriptdate is: it is a pure fold over values the script already holds, with no run, no caller and no state, and the engine's only use of it is to predeclare it.
Index ¶
Constants ¶
const Name = "sum"
Name is the global `sum` is bound to. It is spelled once so the binding, the resolver's view of the environment, and the error messages cannot disagree.
Variables ¶
var Builtin = starlark.NewBuiltin(Name, sumFn)
Builtin adds an iterable of numbers.
Starlark's universe has no sum: min, max, any and all are there, and the one reduction a reporting script performs on every run is not. Totalling a numeric column is the operation these scripts exist to do, and without it every author writes the same four-line accumulator — or, more often, writes sum() from Python instinct and gets `undefined: sum` back.
It follows Python's signature rather than inventing one: sum(iterable, start=0), left to right, an int result when every addend is an int. The values it is pointed at are usually float(r["total"]) over a DECIMAL column, which arrives from SQL as a string.
Functions ¶
This section is empty.
Types ¶
This section is empty.