Skip to content

Update member access design doc to reflect proposal #3720: Member binding operators - #7557

Closed
josh11b wants to merge 4 commits into
carbon-language:trunkfrom
josh11b:member
Closed

Update member access design doc to reflect proposal #3720: Member binding operators#7557
josh11b wants to merge 4 commits into
carbon-language:trunkfrom
josh11b:member

Conversation

@josh11b

@josh11b josh11b commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

The new content reflects the new syntax for function declarations (with #7016 that puts self in (...) and no use of :! due to #7254 ) and updates the BindToRef interface to reflect introduction of ref in #5434 .

See #generics-and-templates and discussion on 2026-08-24 for clarifications on the ambiguous points from #3720.

Assisted-by: Gemini via Antigravity

: Member binding operators

Assisted-by: Gemini via Antigravity
@josh11b
josh11b requested review from a team as code owners July 23, 2026 00:37
@josh11b
josh11b requested review from chandlerc and removed request for a team July 23, 2026 00:37
@github-actions github-actions Bot added the documentation An issue or proposed change to our documentation label Jul 23, 2026

@chandlerc chandlerc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this LGTM, but I think Richard should also take a look to make sure I'm not missing anything...

Comment on lines +1267 to +1273
- The type of an interface method taking `ref self` would also implement `BindToRef(T)`.
- In all cases, the type of an interface member would implement `BindToType(T)` for all types `T impls I`. The result would depend on the specifics of the member, but generally would be a value of a unique empty type associated with the specific interface member, parameterized by `T`. This value could then be bound to an instance of `T` in a succeeding operation.

### Member binding restrictions

The restrictions that only certain compound member accesses are valid are naturally enforced by whether the
member's type implements the required `BindToValue`, `BindToRef`, or `BindToType` interfaces.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth manually wrapping some of this to 80-columns (we don't yet have enforcement from rumdl on this yet)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@chandlerc
chandlerc requested a review from zygoloid August 17, 2026 22:53
Assisted-by: Gemini via Antigravity

@zygoloid zygoloid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to want to replace these interfaces with an ext type generic interface at some point? Or do we think the BindToType/BindToValue/BindToRef split will persist?

Comment on lines +963 to +965
A compound member access expression where the first operand is not used for
`impl` lookup or instance binding is valid, even though the first operand is
redundant.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean? Do we have a blanket BindToValue(T) impl for all types, that just returns self? If not, what Self, T pairs implement BindToValue and return self?

From the below, I think the above is actually wrong, and what we mean is something much narrower: compound member access where the second operand is a non-method function is valid, and forms a bound member access whose Call does not use self. I think all other forms of vacuous compound member access are still invalid, since we don't implement Bind* for them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated based on offline discussion.

// ❌ Error, compound access without impl lookup or instance binding.
// ⚠️ Suspicious (linter warning), but valid: compound access without impl
// lookup or instance binding.
alias X2 = Factory.(Factory.Make);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid? From what we say below, I would conclude:

  • Factory.Make is rewritten to Factory.(<Make function found in Factory>).
  • That uses the BindToType for functions described below, which produces a bound adapter.
  • Bound adapters don't appear to implement Bind*, so Factory.(Factory.Make) is invalid.

But it doesn't really seem clear to me what the intent is here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated based on offline discussion.

// ❌ Error, compound access without impl lookup or instance binding.
// ⚠️ Suspicious (linter warning), but valid: compound access without impl
// lookup or instance binding.
alias X4 = i32.((i32 as Factory).Make);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly I think this is invalid, because (i32 as Factory).Make is rewritten to (i32 as Factory).(<Make found in impl i32 as Factory>), which produces a bound member, and we don't say that that supports further binding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated based on offline discussion.

@josh11b

josh11b commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Are we going to want to replace these interfaces with an ext type generic interface at some point? Or do we think the BindToType/BindToValue/BindToRef split will persist?

The "Primitive member binding interface" section in the current draft of #5389 addresses this.

Assisted-by: Gemini via Antigravity
@josh11b
josh11b requested a review from zygoloid August 19, 2026 22:22
Assisted-by: Gemini via Antigravity
@josh11b

josh11b commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

I'm going to abandon this PR in favor of a proposal to update the member access rules and operations from #3720 .

@josh11b josh11b closed this Sep 1, 2026
@josh11b
josh11b deleted the member branch September 1, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation An issue or proposed change to our documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants