From: zverok.offline@... Date: 2018-01-09T14:01:51+00:00 Subject: [ruby-core:84773] [Ruby trunk Feature#14336] Create new method String#symbol? and deprecate Symbol class Issue #14336 has been updated by zverok (Victor Shepelev). > Victor one thing is the idealisation of a feature another thing is its use in the wild. Yeah, yeah, been told so. I don't know whether it is a right moment to tell it, but just for you to know, I use Ruby since 2004, both for work and hobby project, and stopped idealizing anything in the language... let's say, a while ago. Though, I sometimes smile remembering my crusades in ruby-talk (it was pretty active those days, including regular matz's presence) about how `Time#inspect` is so broken and why NOBODY can see this. > When one thing doesn't match the other there is something broken. > And that is the case. Are you not surprised by how the discussion is going, then? Two or three users are telling about "**everybody** hates", "**people** are confused", "**WE** need to fix this", and everybody else are either indifferent or "nah, nothing is broken here". Don't you think it may be a sign of misjudging the "brokenness" on your side? ---------------------------------------- Feature #14336: Create new method String#symbol? and deprecate Symbol class https://bugs.ruby-lang.org/issues/14336#change-69490 * Author: dsferreira (Daniel Ferreira) * Status: Rejected * Priority: Normal * Assignee: * Target version: ---------------------------------------- From the discussions on the three previous issues related to the String vs Symbol subject ([5964](https://bugs.ruby-lang.org/issues/5964), [7792](https://bugs.ruby-lang.org/issues/7792), [14277](https://bugs.ruby-lang.org/issues/14277)) there are some conclusions we can assume: * Current String vs Symbol is not the ideal scenario. See: Matz and Koichi comments. * Current philosophy is to use Symbols as identifiers and Strings when strings are needed. * Current situation is that Symbols are being used in many code bases as strings except for strings that really need the String methods. * Current situation is that we are designing APIs to handle both String and Symbol inputs forcing an overhead of API development. I propose the deprecation of `Symbol` class and the introduction of `String#symbol?`. ```ruby foo = :foo foo.class # => String foo.symbol? # => true bar = "bar" bar.class # => String bar.symbol? # => false ``` For backwards compatibility transition path I propose: ```ruby class Symbol def self.===(var) warn ("Warning message regarding deprecated class") if var.class == Symbol true elsif var.class == String && var.symbol? true else false end end end class String def is_a?(klass) case klass when String true when Symbol self.symbol? else false end end end ``` -- https://bugs.ruby-lang.org/ Unsubscribe: