Skip to content

Conversation

@syudoer
Copy link

@syudoer syudoer commented Jan 27, 2026

This RFC proposes two new forms of method call syntax for method name disambiguation that keep the receiver on the left and preserve chaining. In doing so, it takes a step towards making implicit selection between trait methods and inherent implementations optional.

An example of a chain of calls using proposed syntax:

obj
    .Self::chain()
    .<Trait1>::of()
    .<Trait2>::method()
    .<Trait1>::calls();

Important

When responding to RFCs, try to use inline review comments (it is possible to leave an inline review comment for the entire file at the top) instead of direct comments for normal comments and keep normal comments for procedural matters like starting FCPs.

This keeps the discussion more organized.

Rendered

@syudoer
Copy link
Author

syudoer commented Jan 27, 2026

This is a direct follow-up to #3908, with a few key differences:

  1. The proposal has evolved significantly since its inception, rendering much of the previous discussion outdated.
  2. The original version was poorly structured and contained too much irrelevant information.

Therefore, I have decided to start with a clean slate.

@syudoer syudoer changed the title natural-method-disambiguation: wrote the RFC RFC: Natural Method Disambiguation Jan 27, 2026
@burdges
Copy link

burdges commented Jan 27, 2026

Afaik we cannot justify two syntaxes for UFC, and the proposed new syntax does not improve over the existing UFC for traits, but if we need clear access to inherent methods then roughly <Type as !>::inherent_method(the_self, ..) clearly says "no traits here".

@programmerjake
Copy link
Member

Afaik we cannot justify two syntaxes for UFC,

why not? we already have multiple different syntaxes for function calls: f(a, b, c) and a.f(b, c). the latter syntax is much more ergonomic for method chains a.f(b).g(c).h(), so it seems logical we'd also want a much more ergonomic equivalent when we need to disambiguate.

and the proposed new syntax does not improve over the existing UFC for traits,

I disagree. It's much more ergonomic to read and write when you have a method chain since you don't have to deal with all the nested parenthesis and reading the functions from the inside out.

but if we need clear access to inherent methods then roughly <Type as !>::inherent_method(the_self, ..) clearly says "no traits here".

I think we also want some syntax for only accessing inherent methods when you're not in a method chain, e.g. because your functions don't have a self argument. In the previous RFC I mentioned that I think <Type as Self>::inherent_function() could work

@Nadrieril
Copy link
Member

If you don't mind both of you, could you start an inline comment thread for this point?

When responding to RFCs, try to use inline review comments (it is possible to leave an inline review comment for the entire file at the top) instead of direct comments for normal comments and keep normal comments for procedural matters like starting FCPs.

This keeps the discussion more organized.

@ehuss ehuss added the T-lang Relevant to the language team, which will review and decide on the RFC. label Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-lang Relevant to the language team, which will review and decide on the RFC.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants