Skip to content

[stack 18/20] spec(gazprea): specify the method-call surface - #129

Closed
Sir-NoChill wants to merge 1 commit into
fix/procedure-call-sitesfrom
feat/method-calls
Closed

[stack 18/20] spec(gazprea): specify the method-call surface#129
Sir-NoChill wants to merge 1 commit into
fix/procedure-call-sitesfrom
feat/method-calls

Conversation

@Sir-NoChill

Copy link
Copy Markdown
Collaborator

Origin: spec-patches/08-feat-method-calls.patch (backlog audit). Substantive normative addition — flagged for close review.

What

Method calls appeared throughout types/vector.rst and types/string.rst with no grammar, receiver rules, or purity story; string.rst invoked a concat method defined nowhere; and append's signature contradicted its own examples.

  • types/vector.rst — new Method Calls subsection (label sssec:vec_methods) covering:
    • Receiver must be a vector or string variable; arrays/slices/expression results have no methods (compile-time TypeError).
    • Method call as statement (unique among expression forms).
    • Purity story for mutating methods (push, append): var receiver, function-local when inside a function.
    • append(x) disambiguated: single-element if promotable, otherwise element-wise; single-element wins ties.
    • Replaced ill-typed (v1 + v2).push(3) example (vector<integer> + vector<real[2]>) with (v1 + v1).push(3) illustrating the array-slice TypeError rule.
  • types/string.rst — cross-links to the new sssec:vec_methods and states strings have exactly the vector method set. Renamed letters.concat("ef")letters.append("ef").

Audit — ambiguities for reviewer attention

This is the largest patch of the backlog and the only feat: — it adds normative surface, not a fix. High-value ambiguities:

  • Receiver types: patch says receivers may be variables only ("no methods on array-valued expression results"). Confirm whether the reference implementation accepts x.len() where x is a literal or a function result; if so, the receiver rule should widen to "any expression whose type is vector/string" and the (v1+v1).push(3) example needs a different justification.
  • Function-local mutation: the purity rule limits mutating methods inside a function to function-local variables. That is stricter than "no mutation of captured/global state". Confirm which framing matches the language semantics — the patch chose the local-only one because it is easier to enforce syntactically.
  • append single-vs-element-wise tie-break: patch declares the single-element reading wins on ambiguity. This is a language design decision — reviewer should confirm this matches the reference implementation. The alternative tie-break (prefer element-wise, or reject ambiguous calls as TypeError) has different ergonomics.
  • Method as statement: "the only expression form that may be used as a statement" — cross-check against expressions.rst and statements.rst. If procedure calls also stand alone (they do, in call statements), the "only" needs qualifying.
  • concatappend rename: this is a breaking change for any existing test programs invoking concat. If existing tests or the reference implementation still expose concat as an alias, that alias needs mentioning in the spec.

Stack

Depends on #128; part of stack #121.

🤖 Backlog patch applied by Claude Code

Method calls appeared throughout vector.rst and string.rst with no
grammar, receiver rules, or purity story, string.rst used a concat
method defined nowhere, and append's signature could not explain its own
examples. Adds a Method Calls subsection (receiver must be a var
vector/string variable; method-call statements; mutating methods on
function-locals preserve purity), defines append's single-element vs
element-wise disambiguation, renames concat to append, and replaces the
ill-typed (v1 + v2).push(3) example (vector<integer> + vector<real[2]>)
with one consistent with the array-slice TypeError rule.

Assisted-by: Agent (claude) <ai@blobfish.icu>
@Sir-NoChill
Sir-NoChill force-pushed the fix/procedure-call-sites branch from 0117ccf to 20fab59 Compare August 21, 2026 19:00
@Sir-NoChill Sir-NoChill changed the title [stack 18/19] spec(gazprea): specify the method-call surface [stack 18/20] spec(gazprea): specify the method-call surface Aug 21, 2026
@Sir-NoChill

Copy link
Copy Markdown
Collaborator Author

Collapsed into #139 — a single consolidated PR of the whole stack (all 40 commits preserved). The flagged questions from this PR are aggregated in #139's description; this branch and thread remain here for reference. Closing in favour of #139.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant