<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't really care about internal representation.<br>
</div><div>That'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's the same as having:<br> LargePositiveInteger>>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"><<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">No, just following ScaledDecimal's example. (0 / 1 is the simplest<br>
zero fraction.)<br>
<br>
But I'm not strongly in favour of what I wrote: if 0 (the integer) is<br>
a more sensible zero for Fraction, I'd be perfectly happy with<br>
removing it and so falling back to Number >> #zero. I'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"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> wrote:<br>
> I wonder about the Fraction implementation.<br>
> Since any Integer isFraction I think it's better to simply let super ^0.<br>
> Synthetizing an unreduced Fraction should be restricted to very specific<br>
> case. Do you have such specific usage?<br>
><br>
> Nicolas<br>
><br>
><br>
> 2013/3/30 <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>><br>
><br>
>> Frank Shearar uploaded a new version of Kernel to project The Trunk:<br>
>> <a href="http://source.squeak.org/trunk/Kernel-fbs.752.mcz" target="_blank">http://source.squeak.org/trunk/Kernel-fbs.752.mcz</a><br>
>><br>
>> ==================== Summary ====================<br>
>><br>
>> Name: Kernel-fbs.752<br>
>> Author: fbs<br>
>> Time: 30 March 2013, 10:09:47.906 pm<br>
>> UUID: 0724a0a2-6b96-4e07-94ed-79bdc4e2466b<br>
>> Ancestors: Kernel-eem.751<br>
>><br>
>> Increase the "polymorphitude" of numbers by supplying a default<br>
>> implementation of #zero, together with a few per-type specialisations to go<br>
>> with those we already have.<br>
>><br>
>> =============== Diff against Kernel-eem.751 ===============<br>
>><br>
>> Item was added:<br>
>> + ----- Method: Float class>>zero (in category 'constants') -----<br>
>> + zero<br>
>> + ^ 0.0.!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: Fraction class>>zero (in category 'constants') -----<br>
>> + zero<br>
>> + ^ self numerator: 0 denominator: 1.!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: Number class>>zero (in category 'constants') -----<br>
>> + zero<br>
>> + ^ 0.!<br>
>><br>
>><br>
><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>