ADR 0023 - Operator coercion + Excel-as-default principle
- Status: accepted
- Date: 2026-05-08
- Spec target: XTL 0.1
- Affects: language.md, ADR-0009, ADR-0017, error-codes.ts
Context
Two distinct gaps surfaced during a spec audit:
-
Mixed-type operator behavior is unspecified. ADR-0009 covers the comparison operators in detail, but the arithmetic operators (
+,-,*,/) and the concatenation operator (&) have no normative table for what happens when operands are mixed types (string + number, Date + number, Boolean + string, etc.). The reference impl silently coerced viatoNumber()which returns 0 for non-numeric strings, masking author bugs. -
No general principle for ambiguity resolution. When the spec is silent on a behavior, every porter has to infer or guess. Without a principle, the inferences accumulate as silent divergence.
This ADR resolves both. It declares Excel as the default reference when XTL is ambiguous, then applies that principle to operator coercion.
Considered Options — operator coercion
A. Coerce silently, defaulting to 0 / empty.
Reference impl behavior pre-ADR. Pro: never errors mid-render. Con:
hides author bugs. [textcolumn] + [number] silently produces
number because text coerces to 0.
B. Type-strict, throw on any mismatch.
Pro: catches bugs early. Con: very strict — "10" + 5 is a common
shape that Excel handles fine.
C. Excel-aligned: coerce numeric-like strings, error on non-numeric. Pro: matches author mental model from Excel. Con: needs explicit table.
Considered Options — ambiguity principle
P-A. Spell out every behavior. Pro: complete. Con: every porter needs every detail; spec gets very long.
P-B. Adopt Excel as the default reference. Pro: most authors come from Excel, mental model is familiar. Con: Excel's behavior itself is sometimes weird (1900 leap year bug, locale-specific format strings); we still need explicit ADRs where Excel diverges from what XTL wants (e.g., XTL's UTC date discipline differs from Excel's locale-naive defaults).
P-C. Adopt JS as the default reference. Pro: matches reference
impl native behavior. Con: porters in non-JS languages would have
to re-implement JS quirks ("10" + 5 === "105"); Excel-shaped
templates would behave surprisingly.
Decision
Adopt option C for operator coercion and option P-B for ambiguity resolution.