From: zverok.offline@... Date: 2018-01-08T14:47:10+00:00 Subject: [ruby-core:84716] [Ruby trunk Bug#14336] Create new method String#symbol? and deprecate Symbol class Issue #14336 has been updated by zverok (Victor Shepelev). To be completely honest, I feel like you are solving the problem that exists for very small percent of Rubyists (I am not saying "non-existent problem" only out of politeness). When people answer you with "removing of `Symbol` will lead to this, that, and that problems", they just give you examples of how `Symbol`s nature deep into Ruby, and why it will never be removed, not ask you to "solve those three problems and we are done". There is absolutely nothing with `Symbol`/`String` difference that needs "fixing", and it is this way for the most of us. `Symbol` is an internal name, `String` is user input, it is neat and useful semantical difference, not "ambiguity" or "bad design". And let it just be this way. ---------------------------------------- Bug #14336: Create new method String#symbol? and deprecate Symbol class https://bugs.ruby-lang.org/issues/14336#change-69436 * Author: dsferreira (Daniel Ferreira) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- 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: