spec+grammar: tuple-vs-arglist rule and explicit tuple spread #4
Loading…
Reference in a new issue
No description provided.
Delete branch "docs/tuple-arg-spread"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Codifies the decided tuple-vs-argument-list rule into the spec and the
canonical grammar:
f(a, b)passes two positional arguments.f((a, b))passes one tuple argument (inline 2-tuple needs the outer parens).f(...t)explicitly spreads a tuple into positional args.This dissolves the arglist-vs-tuple ambiguity a prior review surfaced, keeps
calls deterministic under overloading, and deliberately makes
f((a, b)) ≠ f(a, b)— parentheses are not a semantic no-op in calls.Files
docs/prd/language-spec.mddocs/prd/language-grammar.mdcall-args = call-arg { "," call-arg },call-arg = expr | spread,spread = "..." expr; separateelem-listfor array/init elements; rewrite the paren-disambiguation note around parser position + mode + one bounded peekdocs/parser/30-expressions.mdparse_call_argsnote in the build mapNotes
../...are alreadyDotDot/DotDotDottokens.was agreed after weighing the alternatives: it preserves tuple parameters
as first-class (no forced bound-name staging), stays deterministic under
functionoverloading, and avoids type-directed arglist resolution.Not included (next step, TDD contract)
Per AGENTS.md, a new syntactically-documented feature wants a fixture +
manifest entry. No parser exists yet, so this is codified but not yet under
test. Natural follow-up: add
tests/fixtures/parse/tuple-spread.catand amanifest row (phase
parse) ahead of building the parser.Settled design (Crow): f(a, b) passes two arguments; f((a, b)) passes one tuple argument; f(...t) explicitly spreads a tuple into positional args. - docs/prd/language-spec.md: new 'In argument lists' subsection under Tuples documenting the three forms and that '(' is not a semantic no-op in calls. - docs/prd/language-grammar.md: split call-args = call-arg { ',' call-arg } with call-arg = expr | spread, spread = '...' expr; separate elem-list for array/init elements; rewrite the paren-disambiguation note around parser position + mode + one bounded peek. - docs/parser/30-expressions.md: note the call-args rule in the build map. No lexer change (.. and ... are already DotDot/DotDotDot tokens).