Skip to content
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

"multiple 'self' symbols" #35

Open
njskalski opened this issue Nov 29, 2024 · 0 comments
Open

"multiple 'self' symbols" #35

njskalski opened this issue Nov 29, 2024 · 0 comments

Comments

@njskalski
Copy link

While working in Rust, I noticed that one way to avoid expensive refactors is to defer the decision "which struct/trait should have this method" as long as possible. It allows avoiding "oh, you already took struct X as &mut, you can't now take one of it's field as &" errors.

So I figured, this would actually be a great language feature. Imagine you have function:

fn function(x : &mut X, y: &Y) -> Z {
}

and you can call it with:

let mut x = X::new();
let y = Y::new();
x.function(y)
//or 
(x, y).function();

Then we can discuss if you want to allow reordering, renaming etc, but the gist of it is - let's just stop treating "self" as a magic special argument.

What do you think?

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

No branches or pull requests

1 participant