Mantis - Squeak
Viewing Issue Advanced Details
6454 Collections minor always 04-29-07 13:59 05-01-07 20:03
nicolas cellier  
 
normal  
new 3.9  
open  
none    
none  
0006454: [BUG] An empty Interval has a first and a last element. It should not.
An empty Interval should complain when asked for first or last element, as would super implementation.
child of 0007002new  The Mother of all issues involving interval 
 Interval-EmptyFirstLast-Test.1.cs [^] (472 bytes) 04-29-07 14:01
 Interval-EmptyFirstLast-Patch.1.cs [^] (40,478 bytes) 05-01-07 20:03

Notes
(0010629)
nicolas cellier   
04-29-07 22:14   
since first and last are optimization, and correcting them would make this optimization void, rationale is to remove these methods.

However, users of ParagraphEditor selection and maybe some users of subclass TextLineInterval rely on this behaviour and will fail and recursively open debuggers in case of empty selection...

So this should be indicated with a proper comment.

(0010643)
black   
05-01-07 16:38   
These methods are just broken, and should rasie a subscript out of bounds error on first and last, just like any other empty collection.

Intervals play a dual role: as collections and as regions of the number line. We saw this with includes:, which some thought should mean <= start and <= stop, but didn't: includes: means "is it in the collection". The solution here was to add #rangeIncludes: to do the other thing.

So, perhaps we could add rangeStart and rangeStop as methods to do the other behavior, and make the ParagraphEditor and TextLineInterval subclasses use those messages?

Even with this interpretation, the "optimization" for last is wrong: (1 to: -5 by: 5) last evealuates to -9
(0010644)
nicolas cellier   
05-01-07 20:02   
Yes, agree.
I gave it a try yesterday, and that's a lot of senders to be changed...
I implemented start and stop instead of rangeStart and rangeStop.
I browse for senders of selectFrom:to: selectionInterval lines (Yes TextLineInterval has to be changed too).
Sure i have forgotten a lot...
See the .cs to give an idea

Yet, i did not remove selectors first and last to get the image running...