[ruby-core:89512] Re: [Ruby trunk Bug#15241] net/pop fix to use mutable strings was too eager

From: Eric Wong <normalperson@...>
Date: 2018-10-22 18:31:31 UTC
List: ruby-core #89512
```
[email protected] wrote:
> https://bugs.ruby-lang.org/issues/15241
> See
> [[https://github.com/ruby/ruby/commit/3993fbb5f6bfdae0bce040988d7e2dd632247cdc#commitcomment-30987842|this
> thread on Github]]. I believe the changes made in Backport
> #14416 for 2.5.2 (on both trunk and 2.5.x) over-eagerly
> applied mutability to literal strings. In particular, the
> strings returned by `inspect` have no real need to be mutable
> as far as I can tell.

We cannot make assumptions about how people use strings returned
from .inspect.  Such code exists and we should not break it:

   warn(foo.inspect << " #{__FILE__}:#{__LINE__}")

Disclaimer: I do not speak for the rest of ruby-core.

This worked in 2.2 and earlier, and we should be maintaining
compatibility with such code.  If we have .inspect method
returning frozen strings, I consider it a bug.

I hate that we allocate extra objects and lose performance;
but losing compatibility and breaking existing code is worse.

```

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next