Issue #11782 has been updated by Koichi Sasada.

Status changed from Closed to Assigned

Endo-san pointed out that `+foo.upcase!` is evaluated as `+(foo.upcase!)`.
It can be problem. But any practical examples?

Mutate operations such as `str = +'foo' << bar << baz` works (because +@ is stronger than <<).

Evaluation with current implementation (no optimization)

```
require 'benchmark'

N = 10_000_000
Benchmark.bm{|x|
  x.report{
    N.times{ 'foo'.dup }
  }
  x.report{
    N.times{ +'foo' }
  }
  x.report{
    N.times{ 'foo'.freeze }
  }
  x.report{
    N.times{ -'foo' }
  }
}

__END__
# frozen-string-literal: true
       user     system      total        real
   5.850000   0.010000   5.860000 (  5.858450)
   0.780000   0.000000   0.780000 (  0.780911)
   0.340000   0.000000   0.340000 (  0.351072)
   0.530000   0.000000   0.530000 (  0.529234)

# frozen-string-literal: false
       user     system      total        real
   2.540000   0.000000   2.540000 (  2.533344)
   0.750000   0.000000   0.750000 (  0.752019)
   0.350000   0.000000   0.350000 (  0.349776)
   1.180000   0.000000   1.180000 (  1.180882)
```


----------------------------------------
Feature #11782: String#+@ and String#-@
https://bugs.ruby-lang.org/issues/11782#change-55313

* Author: Koichi Sasada
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
Matz said 

> In fact, my best choice is introducing `String#+` that returns a mutable copy of a string.
[ruby-core:71879] [Ruby trunk - Bug #11759] 

So that this is a ticket for that.
I'll commit it ASAP to check this methods before 2.3.

Specification:

* `+'foo'` returns modifiable string.
* `-'foo'` returns frozen string (because wasters will freeze below 0 degree in Celsius).




-- 
https://bugs.ruby-lang.org/