<div dir="ltr"><div><div><div><div>Yes, 0 is more sensible.<br></div>From the outside that does not matter, because Integer is (or should be) fully polymorphic to Fraction and we don&#39;t really care about internal representation.<br>
</div><div>That&#39;s an implementation detail.<br></div>From the inside, having all Fraction reduced is a valuable invariant: this assumption enables some simplifications of various algorithms (less gcd: computations etc...)<br>
</div>Un-reduced Fractions are rarely used now, only as an intermediate during evaluation of (Integer op Fraction).<br></div><div>IMO, #zero is too general for answering such a Fraction that does not respect the invariants.<br>
</div><div>It&#39;s the same as having:<br>   LargePositiveInteger&gt;&gt;zero<br>       ^self basicNew: self basicSize<br></div><div><br></div>Nicolas<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/3/30 Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">No, just following ScaledDecimal&#39;s example. (0 / 1 is the simplest<br>
zero fraction.)<br>
<br>
But I&#39;m not strongly in favour of what I wrote: if 0 (the integer) is<br>
a more sensible zero for Fraction, I&#39;d be perfectly happy with<br>
removing it and so falling back to Number &gt;&gt; #zero. I&#39;m much more<br>
interested in the protocol.<br>
<br>
frank<br>
<br>
On 30 March 2013 22:35, Nicolas Cellier<br>
<div class="HOEnZb"><div class="h5">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br>
&gt; I wonder about the Fraction implementation.<br>
&gt; Since any Integer isFraction I think it&#39;s better to simply let super ^0.<br>
&gt; Synthetizing an unreduced Fraction should be restricted to very specific<br>
&gt; case. Do you have such specific usage?<br>
&gt;<br>
&gt; Nicolas<br>
&gt;<br>
&gt;<br>
&gt; 2013/3/30 &lt;<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>&gt;<br>
&gt;<br>
&gt;&gt; Frank Shearar uploaded a new version of Kernel to project The Trunk:<br>
&gt;&gt; <a href="http://source.squeak.org/trunk/Kernel-fbs.752.mcz" target="_blank">http://source.squeak.org/trunk/Kernel-fbs.752.mcz</a><br>
&gt;&gt;<br>
&gt;&gt; ==================== Summary ====================<br>
&gt;&gt;<br>
&gt;&gt; Name: Kernel-fbs.752<br>
&gt;&gt; Author: fbs<br>
&gt;&gt; Time: 30 March 2013, 10:09:47.906 pm<br>
&gt;&gt; UUID: 0724a0a2-6b96-4e07-94ed-79bdc4e2466b<br>
&gt;&gt; Ancestors: Kernel-eem.751<br>
&gt;&gt;<br>
&gt;&gt; Increase the &quot;polymorphitude&quot; of numbers by supplying a default<br>
&gt;&gt; implementation of #zero, together with a few per-type specialisations to go<br>
&gt;&gt; with those we already have.<br>
&gt;&gt;<br>
&gt;&gt; =============== Diff against Kernel-eem.751 ===============<br>
&gt;&gt;<br>
&gt;&gt; Item was added:<br>
&gt;&gt; + ----- Method: Float class&gt;&gt;zero (in category &#39;constants&#39;) -----<br>
&gt;&gt; + zero<br>
&gt;&gt; +       ^ 0.0.!<br>
&gt;&gt;<br>
&gt;&gt; Item was added:<br>
&gt;&gt; + ----- Method: Fraction class&gt;&gt;zero (in category &#39;constants&#39;) -----<br>
&gt;&gt; + zero<br>
&gt;&gt; +       ^ self numerator: 0 denominator: 1.!<br>
&gt;&gt;<br>
&gt;&gt; Item was added:<br>
&gt;&gt; + ----- Method: Number class&gt;&gt;zero (in category &#39;constants&#39;) -----<br>
&gt;&gt; + zero<br>
&gt;&gt; +       ^ 0.!<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>