On Mon, 17 May 2004, Simon Strandgaard wrote: > Ara.T.Howard wrote: > > can anyone think of a good reason NOT to have this feature? > > > > class Object > > def copy > > Marshal::load(Marshal::dump(self)) > > end > > end > > > > i include this is nearly all of my own code and i know others do the same > > quite often - why no method which does this? > > In the past I used the very same piece of code for deep copy. > Somewhere I changed my mind from liking it.. to not liking it. > I consider it kludgy to deepcopynig with help of serialize, > and its inefficient compared to custom #clone method. > > Sorry. > > -- > Simon Strandgaard you are right of course: i've written many a custom #clone methods and, for that matter, many custom #dump methods as well - all in the name of speed. i simply feel that the lack of a __builtin__ method to copy objects is one of the very few things, like the lack of a detructor hook (Object#destroy ?), that consistently suprises people and gives the feel of something obviously 'missing' from ruby. the impl is really quite moot - i'm simply advocating something uniform in terms of __interface__ and Object#copy seems like quite a reasonable one. -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 ===============================================================================