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

Comments

Projects
None yet
8 participants
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Sep 4, 2015

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

cc @japaric

@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

nikomatsakis commented Sep 4, 2015

Rather bitrotted PR available here: #23171

@japaric

This comment has been minimized.

Copy link
Member

japaric commented Sep 10, 2015

Rather bitrotted PR available here: #23171

I'm working on a rebase of that PR

@solson

This comment has been minimized.

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 and removed B-RFC-approved labels Nov 9, 2015

@vojtechkral

This comment has been minimized.

Copy link
Contributor

vojtechkral commented Dec 1, 2015

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

@aturon aturon added the T-lang label Jan 27, 2016

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 29, 2016

🔔 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)

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Jan 30, 2016

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

@bluss

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

nikomatsakis commented Feb 18, 2016

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

alexcrichton commented Feb 25, 2016

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

This comment has been minimized.

Copy link
Member

aturon commented Feb 26, 2016

The lang team has likewise decided to stabilize this feature.

Manishearth added a commit to Manishearth/rust that referenced this issue Feb 27, 2016

Rollup merge of rust-lang#31928 - alexcrichton:stabilize-1.8, r=aturon
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 rust-lang#27714
Closes rust-lang#27715
Closes rust-lang#27746
Closes rust-lang#27748
Closes rust-lang#27908
Closes rust-lang#29866
Closes rust-lang#28235
Closes rust-lang#29720

bors added a commit that referenced this issue Feb 27, 2016

Auto merge of #31928 - alexcrichton:stabilize-1.8, r=aturon
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

bors added a commit that referenced this issue Feb 28, 2016

Auto merge of #31928 - alexcrichton:stabilize-1.8, r=aturon
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

bors added a commit that referenced this issue Feb 28, 2016

Auto merge of #31928 - alexcrichton:stabilize-1.8, r=aturon
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

bors added a commit that referenced this issue Feb 29, 2016

Auto merge of #31928 - alexcrichton:stabilize-1.8, r=aturon
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
You can’t perform that action at this time.