Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0007259 [Squeak] Kernel minor always 12-31-08 03:36 04-22-10 20:45
Reporter nicolas cellier View Status public  
Assigned To
Priority normal Resolution open Platform
Status pending   OS
Projection none   OS Version
ETA none Fixed in Version Product Version 3.10
  Product Build
Summary 0007259: Comparing Number and Point
Description After long discusion in VWNC list, I wanted to check Squeak:
(Point < Number) raise an Error
(Number < Point) triggers a coercion
Well, that is not very uniform, but I don't care.
What is more surprising is this:

3.0 <= (2@4) -> false.
3 <= (2@4) -> true.

Argh!
Steps To Reproduce
Additional Information Float <= does trigger the coercion
SmallInteger <= relies on super (Magnitude)

Magnitude assume a total relation order by defining
<= y
    ^(self > y) not

This is wrong for a partial ordered set, notgreaterthan is not an order relation...
After coercion, (3@3) > (2@4) is false,
thus the answer is true...

Solution would be to implement all four selectors < <= > >= in all number subclasses...

But there is still a problem with max: and min: which should better coerce to Point or raise an Error.
(1 max: (2@0)) -> 2@0
(3 max: (2@0)) -> 3
Attached Files  M7259-NumberComparePoint-Patch-nice.1.cs [^] (3,425 bytes) 01-04-09 22:49
 M7259-NumberComparePoint-Test-nice.1.cs [^] (1,395 bytes) 01-04-09 23:04
 M7259-NumberComparePoint-Patch-nice.2.cs [^] (1,169 bytes) 01-04-09 23:29

- Relationships

- Notes
(0012886 - 131 - 137 - 265 - 265 - 265 - 265)
nicolas cellier
12-31-08 03:38

See also http://bugs.squeak.org/view.php?id=3374 [^]
for exact vs inexact comparison and a different coercion strategy for comparisons
 
(0012899 - 530 - 566 - 566 - 647 - 647 - 647)
nicolas cellier
01-04-09 23:27

If retained solution is to raise an Error, then the first patch proposed (nice.1.cs) does include un-needed changes related to 0006719

If retained solution is to coerce to Point (which I do not vote for, but might be necessary - who can analyze the miriades of senders?), then these changes are necessary, because Point is a partially ordered set with current definition of < (> <= >=). In this case, simply add a pre-requisite like (Installer mantis ensureFix: 6719).

This is why I post a second patch, much more lightweight.
 
(0012900 - 220 - 280 - 280 - 280 - 280 - 280)
nicolas cellier
01-04-09 23:31

"fix begin"
Installer mantis ensureFix: 3374.
Installer mantis bug: 7259 fix:'M7259-NumberComparePoint-Patch-nice.2.cs'.
"fix test"
Installer mantis bug: 7259 fix:'M7259-NumberComparePoint-Test-nice.1.cs'.
"fix end"
 
(0013722 - 161 - 251 - 251 - 251 - 251 - 251)
nicolas cellier
04-20-10 20:25

In Squeak 4.1, it works better:

3.0 <= (2@4) -> false.
3 <= (2@4) -> false.

3.0 >= (2@4) -> false.
3 >= (2@4) -> false.

Though:

(24) <= 3 -> Error.
 
(0013727 - 785 - 980 - 980 - 980 - 980 - 980)
wiz
04-22-10 20:45

Ha. Good bug find.

I thought about this a little. My interesting conclusion is that rather than coercing numbers if some policy could be figured out then the ideal thing to do would be to implement x and y for numbers (but not the setters x: or y:)

Choices

1) n x ==> n
n y == y
i.e. the diagonal

2) n x ==> n
n y ==> 0
i.e. the horizontal axis

3) n y ==> n
n x ==> 0
i.e. the vertical axis

Also the policy should decide if the returned number is self or always float.
Choosing always float avoids some sticky situations.

If you choose 2 then you could also implement
n i x ===> 0
n i y ===> n

making imaginaries compatible with point.

the sign of what n i y returns may have to be thought about.

Yours in curiosity and service, --Jerome Peace
 

- Issue History
Date Modified Username Field Change
12-31-08 03:36 nicolas cellier New Issue
12-31-08 03:38 nicolas cellier Note Added: 0012886
01-04-09 22:49 nicolas cellier File Added: M7259-NumberComparePoint-Patch-nice.1.cs
01-04-09 23:04 nicolas cellier File Added: M7259-NumberComparePoint-Test-nice.1.cs
01-04-09 23:27 nicolas cellier Note Added: 0012899
01-04-09 23:29 nicolas cellier File Added: M7259-NumberComparePoint-Patch-nice.2.cs
01-04-09 23:31 nicolas cellier Note Added: 0012900
01-10-09 02:17 Keith_Hodges Status new => pending
04-20-10 20:25 nicolas cellier Note Added: 0013722
04-22-10 20:45 wiz Note Added: 0013727


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
57 total queries executed.
38 unique queries executed.
Powered by Mantis Bugtracker