On Mon, 17 May 2004, Yukihiro Matsumoto wrote:

> Hi,
> 
> In message "Object#copy [rcr?]"
>     on 04/05/17, "Ara.T.Howard" <Ara.T.Howard / noaa.gov> writes:
> 
> |can anyone think of a good reason NOT to have this feature?
> |
> |  class Object
> |    def copy
> |      Marshal::load(Marshal::dump(self))
> |    end
> |  end
> 
> I think deep copy should be implemented independently from
> marshaling, which is inefficient and limited scheme for deep copy.
> The only problem is that it's difficult to implement.
> 
> 							matz.

i see your point... perhaps an initial impl as in above, or even

  class Object
    def copy opts = {'levels'=>42}
      Marshal::load(Marshal::dump(self))
    end
  end

where opts might later affect the semantics of #copy...

i guess i'm more interested in the __interface__ of copying: it would be nice
to be able to write code using

  obj.copy

and nicer still if the impl got faster/better under the hood.  it may not be
the best but, if "everyone's doing it"... ;-)


i understand the 'inefficient' bit above, but what exactly do you have in mind
by 'scheme'?  other that 'how deep' i can't think of other things that might
affect a deep copy?

-a
-- 
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL     :: http://www.ngdc.noaa.gov/stp/
| "640K ought to be enough for anybody." - Bill Gates, 1981
===============================================================================