-
Notifications
You must be signed in to change notification settings - Fork 72
proposal: alternative ergonomic ref count RFC #351
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
proposal: alternative ergonomic ref count RFC #351
Conversation
This goal propses a "friendly fork" of the existing ergonomic ref counting RFC to explore an option that doesn't involve new keywords or changes to the language surface syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello sir you've been tricked by the incorrect values in the template, which I've fixed in #349 and is simply awaiting review at your leisure
src/2025h2/ergonomic-rc.md
Outdated
| Complete seamless implementation | @spastorino | Make `x` equivalent to `x.use` with optional linting | | ||
| Standard reviews | ![Team][] [compiler] | | | ||
| Lang-team champion | @nikomatsakis | | | ||
| Design meetings | ![Team][] [lang] | Two meetings to evaluate both approaches | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI fix
| Design meetings | ![Team][] [lang] | Two meetings to evaluate both approaches | | |
| Design meeting | ![Team][] [lang] | Two meetings to evaluate both approaches | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me on the lang side.
I feel like this goal is missing one of the key criticism about the lack of explicitness. In a sense, some of the examples provided here feel like strawmen, as alternative explicit options could exist which would be much more succinct, and it feels that if implicit solutions are to be evaluated, then clearly they should be evaluated against the most succinct explicit solutions, not the least succinct ones. Should this goal, then, include also offering more succinct, yet still explicit, solutions? For example: // listen for dns connections
let _some_a = self.some_a.clone();
let _some_b = self.some_b.clone();
let _some_c = self.some_c.clone();
let _some_d = self.some_d.clone();
let _some_e = self.some_e.clone();
let _some_f = self.some_f.clone();
let _some_g = self.some_g.clone();
let _some_h = self.some_h.clone();
let _some_i = self.some_i.clone();
let _some_j = self.some_j.clone();
tokio::task::spawn(async move {
// do something with all the values
}); Could be written with a macro: let_clone!(self.{some_a, some_b, some_c, some_d, some_e, some_f, some_g, some_h, some_i, some_j});
tokio::task::spawn(async move {
// Use some_a, some_b, some_c, etc... here
}); Or it could be written with a capture clause (somehow): tokio::task::spawn(async clone(self.{some_a, some_b, some_c, some_d, some_e, some_f, some_g, some_h, some_i, some_j}) move {
// Use some_a, some_b, some_c, etc... here
}); And while, yes, adding/removing a field with the task requires explicitly naming it... it's suddenly far less daunting. I also feel like this goal, much like the previous one, is conflating two objectives:
And I would advocate to focus on the language-level changes, for now, and then discuss separately whether some types in the standard library should be made auto-cloneable. The tolerance-level for what is cheap, and what is not, varies a lot amongst users. I wouldn't mind others being able to mark their type ... which I think perfectly illustrates the point that this goal/RFC may get side-tracked if conflating language-level changes and library-level changes, and that perhaps this goal should focus on first establishing how to change the language, and second how to adjust the standard library to match, as the former greatly impacts the discussion on the latter. |
What I do (and this reduced from some private code that should be open sourced in the future) is have a
This works on current stable rust and is fortunately formatted correctly by |
This goal propses a "friendly fork" of the existing ergonomic ref counting RFC to explore an option that doesn't involve new keywords or changes to the language surface syntax.
@rust-lang/lang -- we should discuss whether this direction makes sense.
Rendered