From a36febf2153bfe3d3c8c636e5e32805e5310f090 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 18 Mar 2004 06:59:04 +0000 Subject: * eval.c: remove specialized version of rb_Array(). use simple one defined in object.c. * object.c (Init_Object): remove Kernel#to_a. * enum.c (enum_zip): use "to_a" instead of "to_ary". git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ array.c | 2 +- enum.c | 2 +- eval.c | 28 ---------------------------- lib/rss/rss.rb | 4 ++-- object.c | 28 ---------------------------- 6 files changed, 13 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index eef6f107b..e0d373eb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Mar 18 15:27:25 2004 Yukihiro Matsumoto + + * eval.c: remove specialized version of rb_Array(). use simple + one defined in object.c. + + * object.c (Init_Object): remove Kernel#to_a. + + * enum.c (enum_zip): use "to_a" instead of "to_ary". + Wed Mar 17 00:22:03 2004 Kazuo Saito * oniguruma.h: imported Oniguruma 2.2.5. diff --git a/array.c b/array.c index b309ea044..058b669a8 100644 --- a/array.c +++ b/array.c @@ -915,7 +915,7 @@ rb_ary_to_ary(obj) return obj; } if (rb_respond_to(obj, rb_intern("to_ary"))) { - return rb_convert_type(obj, T_ARRAY, "Array", "to_ary"); + return to_ary(obj); } return rb_ary_new3(1, obj); } diff --git a/enum.c b/enum.c index cf05219ab..6f69c7973 100644 --- a/enum.c +++ b/enum.c @@ -889,7 +889,7 @@ enum_zip(argc, argv, obj) NODE *memo; for (i=0; im_tbl != RCLASS(rb_mKernel)->m_tbl) { /* exclude Kernel#to_a */ - val = rb_funcall(val, id, 0); - if (TYPE(val) != T_ARRAY) { - rb_raise(rb_eTypeError, "`to_a' did not return Array"); - } - return val; - } - else { - return rb_ary_new3(1, val); - } - } - return tmp; -} -#endif - static VALUE splat_value(v) VALUE v; diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb index d84b51472..6386ca397 100644 --- a/lib/rss/rss.rb +++ b/lib/rss/rss.rb @@ -71,7 +71,7 @@ module RSS class UnknownConversionMethodError < Error attr_reader :to, :from def initialize(to, from) - @to = from + @to = to @from = from super("can't convert to #{to} from #{from}.") end @@ -83,7 +83,7 @@ module RSS attr_reader :string, :to, :from def initialize(string, to, from) @string = string - @to = from + @to = to @from = from super("can't convert #{@string} to #{to} from #{from}.") end diff --git a/object.c b/object.c index bbc9ec539..0e7801fe7 100644 --- a/object.c +++ b/object.c @@ -178,7 +178,6 @@ rb_obj_type(obj) return rb_class_real(CLASS_OF(obj)); } - /* * call-seq: * obj.class => class @@ -316,30 +315,6 @@ rb_obj_init_copy(obj, orig) return obj; } -/* - * call-seq: - * obj.to_a -> anArray - * - * Returns an array representation of obj. For objects of class - * Object and others that don't explicitly override the - * method, the return value is an array containing self. - * However, this latter behavior will soon be obsolete. - * - * self.to_a #=> -:1: warning: default `to_a' will be obsolete - * "hello".to_a #=> ["hello"] - * Time.new.to_a #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"] - */ - - -static VALUE -rb_any_to_a(obj) - VALUE obj; -{ - rb_warn("default `to_a' will be obsolete"); - return rb_ary_new3(1, obj); -} - - /* * call-seq: * obj.to_s => string @@ -2322,7 +2297,6 @@ rb_f_string(obj, arg) return rb_String(arg); } -#if 0 VALUE rb_Array(val) VALUE val; @@ -2345,7 +2319,6 @@ rb_Array(val) } return tmp; } -#endif /* * call-seq: @@ -2507,7 +2480,6 @@ Init_Object() rb_define_method(rb_mKernel, "freeze", rb_obj_freeze, 0); rb_define_method(rb_mKernel, "frozen?", rb_obj_frozen_p, 0); - rb_define_method(rb_mKernel, "to_a", rb_any_to_a, 0); /* to be removed */ rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0); rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0); rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1); -- cgit