<html dir="ltr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style>@font-face {
        font-family: Cambria Math;
}
@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Tahoma;
}
@page Section1 {margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
P {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"
}
SPAN.EmailStyle18 {
        COLOR: #1f497d; FONT-FAMILY: "Calibri","sans-serif"
}
.MsoChpDefault {
        FONT-SIZE: 10pt
}
DIV.Section1 {
        
}
</style>
<meta content="MSHTML 6.00.2900.3243" name="GENERATOR">
<style title="owaParaStyle">P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</style>
</head>
<body lang="EN-GB" vlink="purple" link="blue" ocsi="x">
<div dir="ltr"><font face="Tahoma" size="2"><b>From:</b> ironruby-core-bounces@rubyforge.org [ironruby-core-bounces@rubyforge.org] On Behalf Of Peter Bacon Darwin [bacondarwin@googlemail.com]<br>
<b>Sent:</b> Tuesday, 5 February 2008 6:37 PM<br>
<b>To:</b> ironruby-core@rubyforge.org<br>
<b>Subject:</b> Re: [Ironruby-core] ConvertTo vs Cast<br>
</font></div>
<div></div>
<div>
<div class="Section1">
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Regarding the aside, you can pass Float, Bignum, Complex or any other class you choose to define to the Fixnum#&#43; operator so you do need an overload with
 object.&nbsp; I seem to remember it then coerces the fixnum to whatever the other type is and then calls &#43; on the coerced object.</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="calibri" size="2"></font></span>&nbsp;</p>
<span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="calibri" size="2">
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="Times New Roman" color="#000000" size="3">In Ruby 1.8.6:</font></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font color="#000000"></font></span>&nbsp;</p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="Times New Roman" color="#000000" size="3">Fixnum.instance_method(&quot;&#43;').bind(3.0)</font></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font color="#000000"></font></span>&nbsp;</p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="Times New Roman" color="#000000" size="3">produces:</font></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font color="#000000"></font></span>&nbsp;</p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="Times New Roman" color="#000000" size="3">'bind': bind argument must be an instance of Fixnum (TypeError)</font></span></p>
</font></span>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span>&nbsp;</p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Without looking at the code I can’t comment on the main thrust of the mail, but shouldn’t the local variable i be a Fixnum from the word go and therefore
 call the LessThan(int, int) method anyway?</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="calibri" size="2"></font></span>&nbsp;</p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="Times New Roman" color="#000000" size="3">Yes, LessThan(int, int) is called each time, but an unnecessary call is also made to method ConvertToInt32
 every time around the loop to convert what is already an integer into an integer.</font></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span>&nbsp;</p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><font face="Times New Roman" color="#000000" size="3">Cheers, Wayne.</font></span></p>
</div>
</div>
</body>
</html>