From: Koji Arai Date: 2003-05-05T04:18:18+09:00 Subject: [ruby-dev:20154] Re: Array#map 新井です。 In message "[ruby-dev:20153] Re: Array#map" on 05 May 2003 03:16:56 +0900, matz@ruby-lang.org (Yukihiro Matsumoto) wrote: > まつもと ゆきひろです > |values_at でいいんじゃないかなあ。投げやりでなく。(投票して > |みたいですね) > > values_at実装しました。instance_methods etc.の挙動は(警告を > 付加して)戻してしまいました。 instance_methods etc. とは、引数のデフォルト値のことですよね。 ちょっと戻し方が不完全のようです。 class Foo private; def private_foo() end protected; def protected_foo() end public; def public_foo() end end class Bar < Foo end p Bar.instance_methods - Object.instance_methods p Bar.public_instance_methods - Object.public_instance_methods p Bar.private_instance_methods - Object.private_instance_methods p Bar.protected_instance_methods - Object.protected_instance_methods => ruby 1.6.8 (2002-12-24) [i586-linux] [] [] [] [] => -:10: warning: instance_methods parameter will default to 'true' in Jan 2004 -:10: warning: instance_methods parameter will default to 'true' in Jan 2004 ruby 1.8.0 (2003-05-05) [i586-linux] [] -:11: warning: instance_methods parameter will default to 'true' in Jan 2004 -:11: warning: public_instance_methods parameter will default to 'true' in Jan 2004 -:11: warning: instance_methods parameter will default to 'true' in Jan 2004 -:11: warning: public_instance_methods parameter will default to 'true' in Jan 2004 ["public_foo"] -:12: warning: private_instance_methods parameter will default to 'true' in Jan 2004 -:12: warning: private_instance_methods parameter will default to 'true' in Jan 2004 ["private_foo"] -:13: warning: protected_instance_methods parameter will default to 'true' in Jan 2004 -:13: warning: protected_instance_methods parameter will default to 'true' in Jan 2004 ["protected_foo"] 以下、パッチ後 => -:10: warning: instance_methods parameter will default to 'true' in Jan 2004 -:10: warning: instance_methods parameter will default to 'true' in Jan 2004 ruby 1.8.0 (2003-05-05) [i586-linux] [] -:11: warning: public_instance_methods parameter will default to 'true' in Jan 2004 -:11: warning: public_instance_methods parameter will default to 'true' in Jan 2004 [] -:12: warning: private_instance_methods parameter will default to 'true' in Jan 2004 -:12: warning: private_instance_methods parameter will default to 'true' in Jan 2004 [] -:13: warning: protected_instance_methods parameter will default to 'true' in Jan 2004 -:13: warning: protected_instance_methods parameter will default to 'true' in Jan 200 [] Index: class.c =================================================================== RCS file: /usr/local/cvsup/ruby/ruby/class.c,v retrieving revision 1.61 diff -u -r1.61 class.c --- class.c 4 May 2003 16:02:05 -0000 1.61 +++ class.c 4 May 2003 19:15:47 -0000 @@ -589,7 +589,6 @@ recur = Qtrue; #endif } - if (argc == 0) recur = Qtrue; return method_list(mod, RTEST(recur), ins_methods_prot_i); } @@ -609,7 +608,6 @@ recur = Qtrue; #endif } - if (argc == 0) recur = Qtrue; return method_list(mod, RTEST(recur), ins_methods_priv_i); } @@ -624,14 +622,11 @@ rb_scan_args(argc, argv, "01", &recur); if (argc == 0) { #if RUBY_RELEASE_CODE < 20040101 - rb_warn("instance_methods parameter will default to 'true' in Jan 2004"); + rb_warn("public_instance_methods parameter will default to 'true' in Jan 2004"); #else recur = Qtrue; #endif - rb_warn("public_instance_methods parameter will default to 'true' in Jan 2004"); - /* recur = Qtrue; */ } - if (argc == 0) recur = Qtrue; return method_list(mod, RTEST(recur), ins_methods_pub_i); } @@ -649,7 +644,7 @@ #if RUBY_RELEASE_CODE < 20040101 rb_warn("singleton_methods parameter will default to 'true' in Jan 2004"); #else - recur = Qtrue; + all = Qtrue; #endif } klass = CLASS_OF(obj); values_at はまた後で試します。 -- 新井康司 (Koji Arai)