-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unified function / method call syntax #289
Comments
One reason against it would be that when you unify the syntax, you open up the implementation interface of objects. You would not be able to tell wether a function/method is part of the implementation or not. If you see |
Sorry for interfering guys. To conclude, I'm completely for TJ's variant of UFCS. If not, then let's have at least some 'chaining' operator. EDIT: @m-bra On your worries about sugared free function indistinguishable form method. Rust already has that trouble with extension traits. In fact, this approach (with 'special signature' functions) was used in C#, in a bit different manner. |
This has basically all since been implemented, so closing. |
@tj @alexcrichton This issue is high in the Google results for queries related to Rust and unified call syntax. Could there be links please added to documentation explaining how it works, please? |
See https://github.com/rust-lang/rfcs/blob/master/text/0132-ufcs.md and https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#fully-qualified-syntax-for-disambiguation-calling-methods-with-the-same-name for what is actually implemented. Note that we only support calling |
Thursday Jun 06, 2013 at 14:12 GMT
For earlier discussion, see rust-lang/rust#6974
This issue was labelled with: B-RFC in the Rust repository
I'm not sure how this would play out with internals or if it wouldn't provide enough information to the compiler, but instead of something like:
If possible it would be great to just do something like:
Where
circle.draw(surface)
is just sugar fordraw(circle, surface)
.The text was updated successfully, but these errors were encountered: