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

Tracking issue for overloaded += operators (RFC 953) (feature augmented_assignments) #28235

Closed
nikomatsakis opened this issue Sep 4, 2015 · 11 comments
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

Tracking issue for RFC rust-lang/rfcs#953, which implements support for += operators.

cc @japaric

@nikomatsakis nikomatsakis added the B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. label Sep 4, 2015
@nikomatsakis
Copy link
Contributor Author

Rather bitrotted PR available here: #23171

@japaric
Copy link
Member

japaric commented Sep 10, 2015

Rather bitrotted PR available here: #23171

I'm working on a rebase of that PR

@solson
Copy link
Member

solson commented Sep 23, 2015

It appears the implementation was merged in #28345 (but it's still unstable for now).

@aturon aturon added B-unstable Blocker: Implemented in the nightly compiler and unstable. and removed B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. labels Nov 9, 2015
@vojtechkral
Copy link
Contributor

Hi. What are the requirements to stabilize this feature?

@bluss bluss changed the title Tracking issue for overloaded += operators (RFC 953) Tracking issue for overloaded += operators (RFC 953) (feature augmented_assignments) Jan 20, 2016
@sfackler sfackler added I-nominated T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jan 26, 2016
@aturon aturon added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Jan 27, 2016
@alexcrichton
Copy link
Member

🔔 This issue is now entering its cycle final comment period to be stabilization in 1.8 🔔

Or at least the libs team is willing to stabilize the trait signatures. I believe the lang team is also thinking of having this in FCP for the 1.8 cycle as well (cc @rust-lang/lang)

@alexcrichton alexcrichton added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed I-nominated labels Jan 29, 2016
@aturon
Copy link
Member

aturon commented Jan 30, 2016

The lang team approves final comment period for the entire feature.

@bluss
Copy link
Member

bluss commented Feb 14, 2016

This is a wanted feature in numerical crates of course.

There is one limitation of the current implementation that's appeared in ndarray, and it ties in with something else: There are no custom DSTs in rust. So when we produce an array view (slice of part of an array), we return a new struct type, for example ArrayViewMut<'a, f32>.

The += limitation is that it does not apply on rvalues, so the following does not compile:

//  Increment elements in row `i` by 1.0
array.row_mut(i) += 1.0;
// scale the 4 x 4 top left quadrant by alpha
array.slice_mut(s![..4, ..4]) *= alpha; 

Lifting this restriction doesn't need changing the method signatures.

@nikomatsakis
Copy link
Contributor Author

On Sun, Feb 14, 2016 at 01:19:19AM -0800, bluss wrote:

The += limitation is that it does not apply on rvalues, so the following does not compile:

//  Increment elements in row `i` by 1.0
array.row_mut(i) += 1.0;
// scale the 4 x 4 top left quadrant by alpha
array.slice_mut(s![..4, ..4]) *= alpha; 

Lifting this restriction doesn't need changing the method signatures.

Interesting. I'm happy to see you overloading call notation to get
rvalues like that -- I've been thinking of this as an appealing
alternative to IndexMove (since it preserves the "[] is an lvalue"
concept).

@bluss
Copy link
Member

bluss commented Feb 18, 2016

I realized that the lvalue restriction makes sense. Without it, expressions like string.len() += 1 would compile too, and that's too confusing to allow.

@alexcrichton
Copy link
Member

The libs team discussed this during triage yesterday and this has our stamp of approval. Gonna wait for the lang team to also weigh in on the FCP before stabilizing, however.

@aturon
Copy link
Member

aturon commented Feb 26, 2016

The lang team has likewise decided to stabilize this feature.

@aturon aturon removed the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Feb 26, 2016
bors added a commit that referenced this issue Feb 29, 2016
This commit is the result of the FCPs ending for the 1.8 release cycle for both
the libs and the lang suteams. The full list of changes are:

Stabilized

* `braced_empty_structs`
* `augmented_assignments`
* `str::encode_utf16` - renamed from `utf16_units`
* `str::EncodeUtf16` - renamed from `Utf16Units`
* `Ref::map`
* `RefMut::map`
* `ptr::drop_in_place`
* `time::Instant`
* `time::SystemTime`
* `{Instant,SystemTime}::now`
* `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier`
* `{Instant,SystemTime}::elapsed`
* Various `Add`/`Sub` impls for `Time` and `SystemTime`
* `SystemTimeError`
* `SystemTimeError::duration`
* Various impls for `SystemTimeError`
* `UNIX_EPOCH`
* `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign`

Deprecated

* Scoped TLS (the `scoped_thread_local!` macro)
* `Ref::filter_map`
* `RefMut::filter_map`
* `RwLockReadGuard::map`
* `RwLockWriteGuard::map`
* `Condvar::wait_timeout_with`

Closes #27714
Closes #27715
Closes #27746
Closes #27748
Closes #27908
Closes #29866
Closes #28235
Closes #29720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants