Issue #14336 has been updated by dsferreira (Daniel Ferreira).


The fact that in Smalltalk Symbol is a subclass of String makes perfect sense. 
It is key in the discussion we are having.

Why did Matz tried to unify symbols and strings pior to ruby 1.9?
Because it made sense to do so. The attempt didn”Ēt go well but that outcome didn”Ēt change the situation.
So if it made sense by then to consider symbols and strings equivalent in nature it continuous to make sense today.

Today we have even bigger reasons to consider it because symbols in ruby are having widespread use and the overlap between symbols and strings is growing.

Converting symbols into strings just because we want to metaprogramme some identifiers dynamically (and I do that a lot) and then convert back into symbols because that is what an identifier should be? That is an overlap.
If Symbol class was a subclass of String we wouldn”Ēt have to do so.
And if we didn”Ēt have this convention that identifiers are symbols and text/data are strings we wouldn”Ēt have to worry about it either.

This discussion until now what shows me is that people are justifying the current status quo based on made up conventions totally neglecting the fundamentals.

And the fundamentals are directly related to an attempt that failed.

That failure took ruby to a totally different route. The point of failure was a bifurcation.

Koichi said that if it was possible to get back to the past...

I want to get back to that bifurcation point. The one that is there in the past. Revisit it. Speak with it and try all I can to help ruby select the other route that is also there forgotten and still waiting for us.

Usually we can”Ēt go back to previous missed opportunities but sometimes we are allowed to do so. Ruby 3 is a one time opportunity. And I don”Ēt want us to miss it.

So please stop saying that everything is as it should be because Matz had his say now and has been having it throughout the times.

I”Ēm trying to come up with the best solution (which I don”Ēt know what it is by the way). I will also try to make attempts.
In the end Matz will decide if my efforts were worthy or not.
Meanwhile all your feedback is more than welcome but if you show up just to rant me like many did in this discussion understand that I will not consider any of your lines in my exercise.

I will say it again that I expect someone from the core team to work closely with me as a mentor. Until the day that person exists I will work by myself and this is a commitment.

Many thanks,

Daniel


----------------------------------------
Feature #14336: Create new method String#symbol? and deprecate Symbol class
https://bugs.ruby-lang.org/issues/14336#change-69538

* 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: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>