return rb_str_intern(name);
case T_FIXNUM:
rb_warn(“do not use Fixnums as Symbols”);
@@ -803,5 +803,5 @@ rb_to_id(name)
tmp = rb_check_string_type(name);
if (!NIL_P(tmp)) {
return rb_intern(RSTRING(tmp)->ptr);
return rb_str_intern(tmp);
}
rb_raise(rb_eTypeError, “%s is not a symbol”, RSTRING(rb_inspect(name))->ptr);
Index: string.c
===================================================================
RCS file: /cvs/ruby/src/ruby/string.c,v
retrieving revision 1.156
diff -u -2 -p -r1.156 string.c
— string.c 26 May 2003 08:22:28 -0000 1.156
+++ string.c 20 Jun 2003 10:29:32 -0000
@@ -3073,5 +3073,5 @@ rb_str_intern(str)
if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) {
rb_raise(rb_eArgError, “interning empty string”);
rb_raise(rb_eArgError, “symbol string may not be empty”);
}
if (strlen(RSTRING(str)->ptr) != RSTRING(str)->len)
return SYM2ID(tmp);
case T_FIXNUM:
rb_warn(“do not use Fixnums as Symbols”);
@@ -803,5 +804,6 @@ rb_to_id(name)
tmp = rb_check_string_type(name);
if (!NIL_P(tmp)) {
return rb_intern(RSTRING(tmp)->ptr);
tmp = rb_str_intern(tmp);
return SYM2ID(tmp);
}
rb_raise(rb_eTypeError, “%s is not a symbol”, RSTRING(rb_inspect(name))->ptr);
Sorry, try the patch in [ruby-talk:74014] instead.
Yes, thanks. Works fine now, but there is an incompatibilty with 1.6.8:
obj.send(“”) used to be OK, (dispatched to method_missing), and now gives an error:
in `send’: interning empty string (ArgumentError)
I don’t have a problem with that, but maybe it should be on a caveat list somewhere.
At Sat, 21 Jun 2003 13:35:26 +0900, Yukihiro Matsumoto wrote:
Sorry, try the patch in [ruby-talk:74014] instead.
Commit the fix, please. I will release preview3 afterwards.
What about the message mentioned at [ruby-talk:74012]? Since
that function is also used from String#to_sym not only #intern,
so the current message doesn’t feel appropriate.
Yes, thanks. Works fine now, but there is an incompatibilty with 1.6.8:
obj.send(“”) used to be OK, (dispatched to method_missing), and now gives an error:
in `send’: interning empty string (ArgumentError)
Well, I guess it is caused from:
there’s an incompatiblity for #intern already, which empty
string is not allowed as symbol in 1.8
What about the message mentioned at [ruby-talk:74012]? Since
that function is also used from String#to_sym not only #intern,
so the current message doesn’t feel appropriate.
“intern” is a canonical name for string to symbol operation in the
lisp world. I see no problem.