On 02/20 04:19, Daniel Ferreira wrote:
> If we understand that the concept of Symbols as identifier is valuable
> outside of ruby core (There are people that disagree) then lets
> discuss on that base and see if we can get a solution that can succeed
> in achieving both goals:
> 
> 1. Stop the overlap between Strings and Symbols

What overlap there is you couldn't remove without serious breakage of
backwards compatibility.

> 2. Set Symbols as plain simple identifiers

Symbols already achieve this, unless you are referring to removing the
String methods that were added to them in ruby 1.9, in which case you
also seriously break backwards compatibility.

In my opinion, while it is regrettable that Symbol now has more String
like methods, removing the methods is not worth breaking backwards
compatibility.

> IMHO the overlap between Strings and Symbols in ruby nowadays adds a
> big plus to the ruby language complexity.
> That complexity is the problem I am bringing up for discussion.

Do you have a concrete proposal?  If not, maybe you should take the time
to come up with one (i.e. a patch).  Then that could serve as the basis
for discussion.  Otherwise, it appears you are just rehashing an issue
that has already been decided.  Such a patch could just be a
documentation patch that better explains the difference betwen the two.
Here's an example:

diff --git a/string.c b/string.c
index 5e1769a792..adde02b98e 100644
--- a/string.c
+++ b/string.c
@@ -9559,7 +9559,7 @@ str_scrub_bang(int argc, VALUE *argv, VALUE str)
 /**********************************************************************
  * Document-class: Symbol
  *
- *  <code>Symbol</code> objects represent names and some strings
+ *  <code>Symbol</code> objects represent named identifiers 
  *  inside the Ruby
  *  interpreter. They are generated using the <code>:name</code> and
  *  <code>:"string"</code> literals
@@ -9587,6 +9587,34 @@ str_scrub_bang(int argc, VALUE *argv, VALUE str)
  *     $f2.object_id   #=> 2514190
  *     $f3.object_id   #=> 2514190
  *
+ * Constant, method, and variable names are returned as symbols:
+ *
+ *     module One
+ *       Two = 2
+ *       def three; 3 end
+ *       @four = 4
+ *       @@five = 5
+ *       $six = 6
+ *     end
+ *     seven = 7
+ *
+ *     One.constants
+ *     # => [:Two]
+ *     One.instance_methods(true)
+ *     # => [:three]
+ *     One.instance_variables
+ *     # => [:@four]
+ *     One.class_variables
+ *     # => [:@@five]
+ *     global_variables.last
+ *     # => :$six
+ *     local_variables
+ *     # => [:seven]
+ *
+ * Symbol objects are different from String objects in that
+ * Symbols represent identifiers, while String objects
+ * represent data.
+ *
  */
 
 

Thanks,
Jeremy

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>