-
Notifications
You must be signed in to change notification settings - Fork 176
Flip default for return_ref
#719
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
Comments
For the Generalizing it via In an ideal world with specialization we could work around this via a trait with an assoc type that marks the return type and specializing on |
#582 related |
I'm glad you opened this issue: I strongly think Salsa should default to |
Since this keeps bothering me, I figured I'd take a look at this. It appears that this isn't too much work but there are a few design details. I think going for The other question is whether tracked functions should do the same? I'm guessing yes, is |
If we can't use I don't think it makes sense to apply the same logic to tracked functions: with structs, it's a more akin to field access, but as you've correctly identified with functions, a signature is a bit more sacrosanct. |
Or what about |
Bot Regarding functions, it still feels bad that calling a
implicitly clones. If implicitly rewriting isn't an acceptable default option, maybe having a default of |
It's not really clear to me what the difference of fields and queries is that requires to treat them differently. I think we should have the same default everywhere. It's otherwise very unpredictable and the footgun is the same for fields as it is for queries. |
The footgun is the same, so I think neither should have a clone default. I think it's not a huge deal either way, as long as the default is either ref or copy, so something without much expected cost. I guess having copy on both would be an option, though I have a lot of |
I guess I'll just try to implement the |
Since #772 now got merged, I think this can be revisited. Currently, the default for tracked fields and functions is The solution to this is to swap the default to something that is always cheap. We have basically 2 options:
I'm ok with either one, without a strong preference. Once a default is decided on, implementation should be very easy, thought rewriting all the tests may be a chore. |
I don't have a strong opinion. I'm fine with either |
The default should definitely work for all cases by default, so I'd prefer |
From a user's perspective I would greatly appreciate all salsa helper-attributes being namespaced under |
Uh oh!
There was an error while loading. Please reload this page.
This has come up in #718.
It's very easy to forget a
return_ref
on a non-copy type. On the other hand, returning a ref for acopy
type may be undesired, but the performance consequences are often negligible.Should we change the default for
return_ref
to be true and instead introduce areturn_cloned
.Related: Should we introduce a
return_deref
? There have been a few occasions where I had anOption<T>
and I ended up writing a manual accessor to get the deref behavior. That might also suggest that the syntax should bereturn(cloned)
,return(deref)
return(ref
)?This is a rather subtle breaking change. We should change/decide on this before the first "stable" release.
The text was updated successfully, but these errors were encountered: