
Issue #19450 has been updated by ioquatix (Samuel Williams).
I haven't yet seen a non-contrived example where overriding name will not work
Any time you have nested class or modules in an anonymous module, it gets very ugly.
Examples with invalid constant names already show how this feature could easily be abused.
Already a possible attack surface as demonstrated.
due to how rarely this feature is needed
Since this feature doesn't exist yet, I don't think you can argue that it's rarely used. As stated above, it's used over 100 times in Ruby's own test suite. Other anecdotal evidence suggests this is a fairly common issue as there are a variety of blog posts and SO answers about various ways to achieve it (i.e. overriding `#name`). I've enumerated several key places where I wished this interface existed. I don't see why "rarity of usage" (which is yet to be proven) is a strong argument for "bespoke method names". Can you explain why those two things are related? Are you concerned something is going to break? ---------------------------------------- Feature #19450: Is there an official way to set a class name without setting a constant? https://bugs.ruby-lang.org/issues/19450#change-102101 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- This is the best I could come up with: ```ruby klass = Class.new Object.const_set("Klass", klass) Object.send(:remove_const, "Klass") puts klass.new # => #<Klass:0x0000000100a9d688> ``` Can we do better? What about something like: ```ruby Class.new(name: "Klass") ``` or ```ruby Class.new do def self.name "Klass" end end ``` etc -- https://bugs.ruby-lang.org/