Hi
I find that when I need to do a deep copy that I
usually just do the following:
x = Marshal.load(Marshal.dump(y)
Is there a more concise (possibly faster) method that
combines these two steps? If not, should we add one?
···
–
Jim Freeze
Democracy is good. I say this because other systems are worse.
– Jawaharlal Nehru
<quoting from http://www.rubygarden.org/ruby?ObjectDeepClone >
class Object
def deep_clone
Marshal::load(Marshal.dump(self))
end
end
Jason Creighton
···
On Mon, 21 Jul 2003 18:31:21 +0200 “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com wrote:
On Tue, 22 Jul 2003 01:43:45 +0900, Jim Freeze wrote:
Hi
I find that when I need to do a deep copy that I
usually just do the following:
x = Marshal.load(Marshal.dump(y)
Is there a more concise (possibly faster) method that
combines these two steps? If not, should we add one?
How about this ?
http://www.rubygarden.org/ruby?StandardClassExtensions/Object
Looks good. Has there been any discussion on this?
···
On Tuesday, 22 July 2003 at 1:43:22 +0900, Simon Strandgaard wrote:
On Tue, 22 Jul 2003 01:43:45 +0900, Jim Freeze wrote:
Hi
I find that when I need to do a deep copy that I
usually just do the following:
x = Marshal.load(Marshal.dump(y)
Is there a more concise (possibly faster) method that
combines these two steps? If not, should we add one?
How about this ?
http://www.rubygarden.org/ruby?StandardClassExtensions/Object
–
Jim Freeze
All men are mortal. Socrates was mortal. Therefore, all men are
Socrates.
– Woody Allen
Robert
(Robert)
21 July 2003 17:04
5
“Jason Creighton” androflux@softhome.net.remove.to.reply schrieb im
Newsbeitrag
news:20030721103047.708f65ad.androflux@softhome.net.remove.to.reply…
···
On Mon, 21 Jul 2003 18:31:21 +0200 > “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com wrote:
On Tue, 22 Jul 2003 01:43:45 +0900, Jim Freeze wrote:
Hi
I find that when I need to do a deep copy that I
usually just do the following:
x = Marshal.load(Marshal.dump(y)
Is there a more concise (possibly faster) method that
combines these two steps? If not, should we add one?
How about this ?
http://www.rubygarden.org/ruby?StandardClassExtensions/Object
<quoting from http://www.rubygarden.org/ruby?ObjectDeepClone >
class Object
def deep_clone
Marshal::load(Marshal.dump(self))
end
end
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
Ahem…
robert
That’s nice, but it is not in 1.8…yet.
···
On Tuesday, 22 July 2003 at 2:03:51 +0900, Jason Creighton wrote:
On Mon, 21 Jul 2003 18:31:21 +0200 > “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com wrote:
On Tue, 22 Jul 2003 01:43:45 +0900, Jim Freeze wrote:
Hi
I find that when I need to do a deep copy that I
usually just do the following:
x = Marshal.load(Marshal.dump(y)
Is there a more concise (possibly faster) method that
combines these two steps? If not, should we add one?
How about this ?
http://www.rubygarden.org/ruby?StandardClassExtensions/Object
<quoting from http://www.rubygarden.org/ruby?ObjectDeepClone >
class Object
def deep_clone
Marshal::load(Marshal.dump(self))
end
end
–
Jim Freeze
If entropy is increasing, where is it coming from?
Just keep in mind that not everything can be marshalled. If
#deep_clone appeared in the language implemented like this, people
might get surprised when their Binding, IO, Proc, and singleton
objects aren’t cloned. Just maybe…
Gavin
···
On Tuesday, July 22, 2003, 3:03:51 AM, Jason wrote:
I find that when I need to do a deep copy that I
usually just do the following:
x = Marshal.load(Marshal.dump(y)
Is there a more concise (possibly faster) method that
combines these two steps? If not, should we add one?
[…]
class Object
def deep_clone
Marshal::load(Marshal.dump(self))
end
end
If I read the reports correctly, “Molly” the clone
had a ticking time bomb. (Maybe a thread with
a lifetime?)
Jim Freeze
···
On Tuesday, 22 July 2003 at 2:04:28 +0900, Robert Klemme wrote:
“Jason Creighton” androflux@softhome.net.remove.to.reply schrieb im
Newsbeitrag
news:20030721103047.708f65ad.androflux@softhome.net.remove.to.reply…
On Mon, 21 Jul 2003 18:31:21 +0200 > > “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com wrote:
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
I was just pointing out that the method listed at
http://www.rubygarden.org/ruby?StandardClassExtensions/Object is the same
thing you were doing: Using Marshal.
Jason Creighton
···
On Tue, 22 Jul 2003 02:05:18 +0900 Jim Freeze jim@freeze.org wrote:
<quoting from http://www.rubygarden.org/ruby?ObjectDeepClone >
class Object
def deep_clone
Marshal::load(Marshal.dump(self))
end
end
That’s nice, but it is not in 1.8…yet.
Next it will be Jim.freeze :=>
···
On Tue, Jul 22, 2003 at 02:04:28AM +0900, Robert Klemme wrote:
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
Robert
(Robert)
22 July 2003 04:48
11
“Jim Freeze” jim@freeze.org schrieb im Newsbeitrag
news:20030721131453.C23234@freeze.org …
···
On Tuesday, 22 July 2003 at 2:04:28 +0900, Robert Klemme wrote:
“Jason Creighton” androflux@softhome.net.remove.to.reply schrieb im
Newsbeitrag
news:20030721103047.708f65ad.androflux@softhome.net.remove.to.reply…
On Mon, 21 Jul 2003 18:31:21 +0200 > > > “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com wrote:
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
If I read the reports correctly, “Molly” the clone
had a ticking time bomb. (Maybe a thread with
a lifetime?)
Yeah, possibly.
robert
Robert
(Robert)
22 July 2003 08:11
12
“Brian Candler” B.Candler@pobox.com schrieb im Newsbeitrag
news:20030722070229.GA42211@uk.tiscali.com …
···
On Tue, Jul 22, 2003 at 02:04:28AM +0900, Robert Klemme wrote:
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
Next it will be Jim.freeze :=>
LOL
unless Jim.frozen?
Jim.post “comp.lang.ruby”
end
…
robert
But does comp.lang.ruby support postconditions?
martin
···
Robert Klemme bob.news@gmx.net wrote:
“Brian Candler” B.Candler@pobox.com schrieb im Newsbeitrag
news:20030722070229.GA42211@uk.tiscali.com …
On Tue, Jul 22, 2003 at 02:04:28AM +0900, Robert Klemme wrote:
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
Next it will be Jim.freeze :=>
LOL
unless Jim.frozen?
Jim.post “comp.lang.ruby”
end
I’ll have you know that the #freeze method is copyrighted by
myself. My lawyers inform me that every line of Ruby code written
that contains #freeze is subject to legal action or usage fees.
(You may want to use it sparingly in your code.)
However, #frozen is deemed an original work and is not legally
actionable.
···
On Tuesday, 22 July 2003 at 17:11:48 +0900, Robert Klemme wrote:
“Brian Candler” B.Candler@pobox.com schrieb im Newsbeitrag
news:20030722070229.GA42211@uk.tiscali.com …
On Tue, Jul 22, 2003 at 02:04:28AM +0900, Robert Klemme wrote:
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
Next it will be Jim.freeze :=>
LOL
unless Jim.frozen?
Jim.post “comp.lang.ruby”
end
–
Jim Freeze
“Never underestimate the power of a small tactical nuclear weapon.”
Robert
(Robert)
22 July 2003 11:53
15
“Jim Freeze” jim@freeze.org schrieb im Newsbeitrag
news:20030722065046.A25287@freeze.org …
“Brian Candler” B.Candler@pobox.com schrieb im Newsbeitrag
news:20030722070229.GA42211@uk.tiscali.com …
Even more efficient:
class Object
def sheep_clone(); “Molly”.dup; end
end
Next it will be Jim.freeze :=>
LOL
unless Jim.frozen?
Jim.post “comp.lang.ruby”
end
I’ll have you know that the #freeze method is copyrighted by
myself. My lawyers inform me that every line of Ruby code written
that contains #freeze is subject to legal action or usage fees.
(You may want to use it sparingly in your code.)
Ah, I’ve wondered why it is so seldomly used. Now that’s clear ™.
However, #frozen is deemed an original work and is not legally
actionable.
Ok, fine. Thank’s for letting uns know.
“Never underestimate the power of a small tactical nuclear weapon.”
Oops…
robert
···
On Tuesday, 22 July 2003 at 17:11:48 +0900, Robert Klemme wrote:
On Tue, Jul 22, 2003 at 02:04:28AM +0900, Robert Klemme wrote: