ts wrote:

....
> P> 3. Should dup be implemented in terms of clone or should clone be
> P>    implented in terms of dup (or should they both be implemented
> P>    independently or in terms of another function)?
> 
>  For 1.6 Kernel#dup is implemented via Kernel#clone 
> 
>  1.8 use #initialize_copy

When redefining #initialize_copy it might be vice or
a virtue to call or not to call or when to call "super" -
for example

---
class AccessHash < Hash
   def initialize
     @accessed = 0
     super
   end
   def [](key)
     @accessed += 1
     super
   end

   def out
     p self, @accessed
   end

   protected
   attr_reader :accessed

   # first try
   def initialize_copy(orig)
     @accessed = 0 # reset @accessed
   end
end

h = AccessHash.new
h[1] = 1
h[2]
h[1]


h.clone.out # {} -  uups, empty AccessHash
             # 0

class AccessHash < Hash
   def initialize_copy(orig)
     super
   end
end

h.clone.out # {1=>1}
             #  2 -  uups, @accessed is wrong

class AccessHash < Hash
   def initialize_copy(orig)
     @accessed = 0
     super
   end
end

h.clone.out # {1=>1}
             # 0 - works, interesting!!!

# okay just checking

class AccessHash < Hash
   def initialize_copy(orig)
     super
     @accessed = 0
   end
end

h.clone.out # {1=>1}
             # 0
---

/Christoph