logo       

Re: [FIX] SortedCollectionFix-sr: msg#00788

lang.smalltalk.squeak.general

Subject: Re: [FIX] SortedCollectionFix-sr

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

Stephan Rudlof <sr@xxxxxxxxx> 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.)





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise