ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: naruse@airemix.jp
To: ruby-core@ruby-lang.org
Subject: [ruby-core:100998] [Ruby master Bug#10845] Subclassing String
Date: Sat, 21 Nov 2020 05:35:15 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-88665.20201121053514.2963@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-10845.20150210234125.2963@ruby-lang.org

Issue #10845 has been updated by naruse (Yui NARUSE).


In 2.7 we break large compatibilities, and this tickets breaks Rails again.
"Rails master already fixes it" doesn't care the problem; we breaks compatibility.

Breaking compatibility itself is not problem, but we can provide very small benefit for Rails application in 2.7 and 3.0.
We only provide disadvantages in recent versions.
Ractor and types are great milestone for future Rails, but they are not for Rails at this time.

I'm serious about the motivation of upgrading to Ruby 3.0 for Rails users.
I worry that so much.

----------------------------------------
Bug #10845: Subclassing String
https://bugs.ruby-lang.org/issues/10845#change-88665

* Author: sawa (Tsuyoshi Sawada)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* ruby -v: 2.2
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
If I make a subclass of `String`, the method `*` returns an instance of that class.

~~~ruby
class MyString < String
end

MyString.new("foo").*(2).class #=> MyString
~~~

This is different from other similar operations like `+` and `%`, which return a `String` instance.

~~~ruby
MyString.new("foo").+("bar").class #=> String
MyString.new("%{foo}").%(foo: "bar").class #=> String
~~~

I don't see clear reason why `*` is to be different from `+` and `%`, and thought that perhaps either the behaviour with `*` is a bug, or the behaviour with `+` and `%` is a bug.

Or, is a reason why they are different?



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

  parent reply	other threads:[~2020-11-21  5:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-10845.20150210234125.2963@ruby-lang.org>
2020-10-25 22:39 ` [ruby-core:100540] [Ruby master Bug#10845] Subclassing String merch-redmine
2020-11-20  6:16 ` [ruby-core:100958] " matz
2020-11-20  7:33 ` [ruby-core:100963] " ronnie
2020-11-20 10:18 ` [ruby-core:100972] " samuel
2020-11-20 12:47 ` [ruby-core:100976] " eregontp
2020-11-20 16:45 ` [ruby-core:100983] " merch-redmine
2020-11-20 19:34 ` [ruby-core:100992] " eregontp
2020-11-21  0:37 ` [ruby-core:100995] " merch-redmine
2020-11-21  5:35 ` naruse [this message]
2020-11-21  7:31 ` [ruby-core:101000] " merch-redmine
2020-11-21  7:45 ` [ruby-core:101001] " marcandre-ruby-core
2020-11-21 12:25 ` [ruby-core:101004] " eregontp
2020-11-22 16:31 ` [ruby-core:101017] " yasuo.honda
2020-11-22 16:58 ` [ruby-core:101018] " eregontp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-88665.20201121053514.2963@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).