[FIX] SortedCollectionFix-sr

Richard A. O'Keefe squeak-dev at lists.squeakfoundation.org
Mon Sep 30 03:57:19 UTC 2002


I noted that SortedCollection>>reversed produces an invalid answer.

Stephan Rudlof <sr at evolgo.de> replied:
	There may be a problem:  if you apply >>reversed multiple times
	the opposite comparison sortBlock becomes bigger and bigger, if
	the implementation just inverts it by constructing a new one
	with sending #not to the old.

As you say, IF.  (Although #not is DEFINITELY the wrong thing to do.
We want to turn <= into >+, not into > .)

	There are other implementations possible, though.
	
And indeed there are.

One of them is to introduce a new class

    Object subclass: #BinaryBlockConverse
        instanceVariables: 'block'
        ....

    beConverseOf: aBlock
	block := aBlock

    converse
	^aBlock
	
    value: x value: y
	^block value: y value: x

    class>>
    of: aBlock
	^self new beConverseOf: aBlock

and a new method in BlockContext

    converse
	self assert: [self numArgs = 2].
	^BinaryBlockConverse of: self

I've just sent a change set "converse-raok" that basically does this.
(No, it doesn't change SortedCollection reversed.)




More information about the Squeak-dev mailing list