Status: Resolved Date: 2026-02-28 Triggered by: GAPS.md — "Ergonomic dispatch on variable-length ordered data"
Pattern matching handles tuples (fixed-length), enums, structs — not lists (variable-length). Surfaced from CLI subcommand dispatch on List[Str] command paths, but applies broadly: JSON traversal, token parsing, protocol dispatch.
[pattern, ...] syntax in pattern position, matching list values by length and element values.
| Expert | Vote | Reasoning |
|---|---|---|
| Systems | Yes | Natural extension of tuple patterns. Lists are the universal collection |
| Web/Scripting | Yes | JS/TS destructuring proves the pattern. Essential for ergonomic code |
| PLT | Yes | Well-understood in ML family. Square brackets unambiguous in pattern position |
| DevOps | Yes | CLI dispatch is the motivating case. if/else chains are error-prone |
| AI/ML | Yes | LLMs generate list matching confidently — familiar from Python/JS/Rust |
Result: 5-0 Yes
Options: (A) [first, ...rest] binds rest as new list (requires O(n) copy or slice type), (B) [first, ...] wildcard only, no binding.
| Expert | Vote | Reasoning |
|---|---|---|
| Systems | B | Copy is O(n), slice type adds complexity. Use .slice() explicitly |
| Web/Scripting | B | Wildcard covers 90% of cases. Binding can come later with slices |
| PLT | B | Rest binding needs a slice type to be zero-cost. Defer to v2 |
| DevOps | A | Full binding is more useful. Worth the copy for ergonomics |
| AI/ML | B | Simpler mental model for LLMs. One fewer concept to learn |
Result: 4-1 wildcard only (DevOps dissented)
Lists are unbounded — finite length patterns can never be exhaustive. How to enforce coverage?
| Expert | Vote | Reasoning |
|---|---|---|
| All | Length-based + mandatory wildcard | Track covered lengths; require _ or ... catch-all arm. [] + [_, ...] IS exhaustive (covers empty + non-empty) |
Result: 5-0 consensus
| Criterion | Pass/Fail | Notes |
|---|---|---|
| Learnability | Pass | Familiar from JS/Python destructuring |
| Consistency | Pass | Mirrors tuple pattern syntax with [] instead of () |
| Generability | Pass | LLMs generate list patterns confidently |
| Debuggability | Pass | Length-based errors are clear and actionable |
| Token efficiency | Pass | More concise than equivalent if/else chains |
Add list patterns with wildcard-only rest. Length-based exhaustiveness with mandatory catch-all for unbounded lists.