On Feb 16, 2007, at 1:50 PM, Phrogz wrote:
> Having said that, I personally would prefer for 3.dup to 'just work',
> returning an object that is equivalent to the original. Just because
> the new instance happens to be the same doesn't mean that it's bad -
> as an immutable object, the only way to tell is via object_id, anyhow.

I've come across this situation when writing generic code to do a
'deep copy'.  Instead of changing the semantics of #dup, why not have
some other method that means 'make a copy if you can but if the object
has immutable semantics then return a reference to self'.

As for a name for such a method, how about Kernel#another ?

I'm not sure how #dup, #clone, and #another should be related.  Perhaps
#another should use #clone instead of #dup?  Maybe there should be  
another
version of #another that uses clone semantics?

Gary Wright