borgo icon indicating copy to clipboard operation
borgo copied to clipboard

"multiple 'self' symbols"

Open njskalski opened this issue 11 months ago • 0 comments

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?

njskalski avatar Nov 29 '24 10:11 njskalski