[#44909] VRDdeClientについて — Toshiyasu Soejima <clev@...2.so-net.ne.jp>

17 messages 2008/05/11

[#44936] yamlとencoding — "Yutaka Kanemoto" <kinpoco@...>

金本と申します。

16 messages 2008/05/14

[ruby-list:44914] Re: SimpleDelegator#dupの引数objについて

From: Nobuyoshi Nakada <nobu@...>
Date: 2008-05-11 15:50:29 UTC
List: ruby-list #44914
なかだです。

At Mon, 12 May 2008 00:01:48 +0900,
SHIMADA Koji wrote in [ruby-list:44913]:
> 上記について、ruby-1.8.7-preview2ではまだ上記引数が残ったままですが,
> 次の preview もしくは本リリース時には修正されますでしょうか?

単なるバックポートミスだろうと思います。1.8.6でも直すべきでしょ
う。

また、dup/cloneされたときに元のobjectのほうを置き換えているのも、
1.9のようにコピーされたほうにセットしなおすほうがいいような。と
いうか、initialize_copyを使ってないのはなんででしょう。


Index: lib/delegate.rb
===================================================================
--- lib/delegate.rb	(revision 16366)
+++ lib/delegate.rb	(working copy)
@@ -228,11 +228,13 @@ class SimpleDelegator<Delegator
   # Clone support for the object returned by \_\_getobj\_\_.
   def clone
-    super
-    __setobj__(__getobj__.clone)
+    new = super
+    new.__setobj__(__getobj__.clone)
+    new
   end
   # Duplication support for the object returned by \_\_getobj\_\_.
-  def dup(obj)
-    super
-    __setobj__(__getobj__.dup)
+  def dup
+    new = super
+    new.__setobj__(__getobj__.clone)
+    new
   end
 end
@@ -281,10 +283,12 @@ def DelegateClass(superclass)
     end
     def clone  # :nodoc:
-      super
-      __setobj__(__getobj__.clone)
+      new = super
+      new.__setobj__(__getobj__.clone)
+      new
     end
     def dup  # :nodoc:
-      super
-      __setobj__(__getobj__.dup)
+      new = super
+      new.__setobj__(__getobj__.clone)
+      new
     end
   }


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread