Issue 4949 in pharo: Integer should be polymorphic with Fraction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo
Status: Accepted
Owner: [hidden email]
Labels: Type-Cleanup

New issue 4949 by [hidden email]: Integer should be polymorphic with  
Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

Fraction are automatically reduced to Integer
It is thus impossible to guaranty that the sum of two Fraction will be a  
Fraction. For example, (((a/b)+(c/d)) denominator) might fail un-understood.
It is thus logical to let Integer behave polymorphically to Fraction.

This change was introduced in Squeak:
- let Integer answer to #numerator/#denominator
- let Integer answer true to isFraction (it behaves like a Fraction)
- let conversion asFraction ^self
- change adaptToFraction:andSend: to really create a (Fraction  
numerator:denominator:) when necessary

This change also fast-up some mixed operations because they now avoid an  
intermediate Fraction creation.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo
Updates:
        Status: FixReviewNeeded
        Labels: Milestone-1.4

Comment #1 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo

Comment #2 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

I forgot to say I put a SLICE in the inbox for review.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo

Comment #3 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

Also note that 2.0 asFraction isFraction would now be true, which is a nice  
thing to have.

Indeed, it is a Fraction with numerator 2 and (implicit) denominator 1,  
undistinguishable from the Integer 2...
That's why 2.0 asFraction isInteger is also true of course...

A drawback is that isFraction did implicitely mean isInteger not, but does  
not anymore... I did not find any such usage, and it would be easy to  
change the send place into (_ isFraction and: [_ isInteger not]) if we ever  
find one.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo

Comment #4 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

I added a couple of tests, but now I wonder: If Integer is polymorphic with  
Fraction... what's the meaning of #adaptToFraction:andSend: ... I mean, It  
wont be called ever... or I'm wrong?


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo

Comment #5 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

Great Esteban, it seems that we can indeed remove on more method :)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo

Comment #6 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

so can we integrate this changes?

Now a integer is a fraction with 1 as denominator
and a fraction is necessary for other fractional number?
Is it that?

What are the other messages of fraction than an integer should understand?  
Only numerator and denominator?


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo
Updates:
        Status: FixToInclude

Comment #7 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4949 in pharo: Integer should be polymorphic with Fraction

pharo
Updates:
        Status: Integrated

Comment #8 on issue 4949 by [hidden email]: Integer should be  
polymorphic with Fraction
http://code.google.com/p/pharo/issues/detail?id=4949

in 14259


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker