Except that arithmetic on Fraction isExact, or should I say is: #exact, while on Float is not, so definitely a Float is not a Fraction, even if its internal representation is a Fraction.
2013/6/25 Igor Stasenko <siguc...@gmail.com> > On 25 June 2013 13:34, Nicolas Cellier > <nicolas.cellier.aka.n...@gmail.com> wrote: > > That does not answer my problem. > > 2 both is: #fraction (with 1 denominator) and is: #integer so how do you > > implement? > > or: [super is: #number] ? > > > > i know you can give plenty of ideas how you would do it, like: > > #(foo bar baz) includes: yourQuery > > but i wouldn't recommend it :) > > > Btw i find it really strange, why for Integer it answers true, > but not for Floats > > i actually would expect that: > > 10e50 isFraction > 0.5 isFraction > should also answer true > > because the floating-point numbers, which we are using in computers, > can be represented by a fraction. > And only those, which cannot be represented by fraction (like Pi) > should answer false. > So, please, fix it, and then we will think how to better implement > polymorphic check with single #is: method :) > > > > > 2013/6/25 Igor Stasenko <siguc...@gmail.com> > >> > >> On 25 June 2013 12:47, Nicolas Cellier > >> <nicolas.cellier.aka.n...@gmail.com> wrote: > >> > But in some cases, you will end up with an object that is more than > one > >> > thing: > >> > - a Number > >> > - an Integer > >> > - a Fraction > >> > For example 0 shall answer yes to these 3. > >> > So ^foo == #specialName just does not work, or you end up with caseOf: > >> > > >> > >> err, why? > >> > >> if you define it like: > >> > >> Number>>is: symbol > >> ^ symbol == #number > >> > >> > >> 0 is: #number => true > >> 0.0 is: #number => true > >> 0/1 is: #number => true > >> ? > >> > >> It is actually up to implementor how to his own classes should process > >> #is: message. > >> The only invariant (which imo best one), that Object should always > >> answer false to #is: message no matter what parameter you passed, to > >> avoid any ambiguous cases and keep things simple and easy to remember. > >> That means, that unless you override this method in own class, its > >> instances will always answer false to #is: message. > >> And when you override it, you are free to define it the way you like... > >> > >> MyClass>>is: foo > >> ^ foo class == self class > >> or > >> MyClass>>is: foo > >> ^ foo class name == self class name > >> or > >> > >> MyClass>>is: foo > >> ^ foo isKindOf: MyClass > >> > >> (no limits to imagination :) > >> > >> -- > >> Best regards, > >> Igor Stasenko. > >> > > > > > > -- > Best regards, > Igor Stasenko. > >