------art_44742_2215787.1216602632873
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I write a lot of hand crafted dup or clone because I want control as well as
better performance than the Marshal idiom. I ended up re-opening NilClass,
TrueClass and FalseClass for def dup; self; end
While most of the things in Ruby are very intuitive and predictable from
functional perspective, this sort of stood out.. that's all.
Nasir
On Sun, Jul 20, 2008 at 6:04 PM, Kurt Stephens <ks / kurtstephens.com> wrote:

> Urabe Shyouhei wrote:
> > Meinrad Recheis wrote:
> >>> I don't think so. Nil is _the_ nil, one and only instance of NilClass.
> >>> Duping it doesn't make sense to me.  And a dup method to return
> >>> identical object is just strange.
> >>>
> >> it makes sense to me, to implement dup on singleton objects like nil to
> >> implement deep copying of arrays and hashes.
> >>
> >
> > Marshal.load(Marshal.dump(obj)) and you get a deep copy of obj.  This is
> > a well known idiom.  Any other chances for you to need a dup of nil?
> >
>
> Marshal.load(Marshal.dump(obj)) is far more expensive than a well-crafted
> #dup
> method and less semantically controllable.
>
> Kurt Stephens
>
>
>

------art_44742_2215787.1216602632873
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dirtr"><div>I write a lot of hand crafted dup or clone because I want control as well as better performance than the Marshal idiom. I ended up re-opening NilClass, TrueClass and FalseClass for def dup; self; end</div>

<div>While&nbsp;most of the things&nbsp;in Ruby are very intuitive&nbsp;and predictable from functional perspective, this sort of stood out.. that&#39;s all.&nbsp;&nbsp;<br></div>
<div>Nasir<br></div>
<div classmail_quote">On Sun, Jul 20, 2008 at 6:04 PM, Kurt Stephens &lt;<a hrefailto:ks / kurtstephens.com">ks / kurtstephens.com</a>&gt; wrote:<br>
<blockquote classmail_quote" styleADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div classh2E3d">Urabe Shyouhei wrote:<br>&gt; Meinrad Recheis wrote:<br>&gt;&gt;&gt; I don&#39;t think so. Nil is _the_ nil, one and only instance of NilClass.<br>&gt;&gt;&gt; Duping it doesn&#39;t make sense to me. &nbsp;And a dup method to return<br>
&gt;&gt;&gt; identical object is just strange.<br>&gt;&gt;&gt;<br>&gt;&gt; it makes sense to me, to implement dup on singleton objects like nil to<br>&gt;&gt; implement deep copying of arrays and hashes.<br>&gt;&gt;<br>&gt;<br>
&gt; Marshal.load(Marshal.dump(obj)) and you get a deep copy of obj. &nbsp;This is<br>&gt; a well known idiom. &nbsp;Any other chances for you to need a dup of nil?<br>&gt;<br><br></div>Marshal.load(Marshal.dump(obj)) is far more expensive than a well-crafted #dup<br>
method and less semantically controllable.<br><font color888888"><br>Kurt Stephens<br><br><br></font></blockquote></div><br></div>

------art_44742_2215787.1216602632873--