[FIX] OrderedCollection
Stephan Rudlof
sr at evolgo.de
Mon May 22 16:38:22 UTC 2000
Bert Freudenberg wrote:
>
> On Sun, 21 May 2000, Stephan Rudlof wrote:
>
> > But there remains the bug of
> >
> > SequenceableCollection>>collect: aBlock from: firstIndex to: lastIndex
> > "Refer to the comment in Collection|collect:."
> > | result |
> > result _ self species new: lastIndex - firstIndex + 1.
> > firstIndex to: lastIndex do: [:index | result at: index put: (aBlock
> > value: (self at: index))].
> > ^ result
> >
> > for ArrayedCollections; evaluate:
> > #( 1 2 3) collect: [:e | e printString] from: 2 to: 3
> > , to generate an error (I have checked this! ;-) ).
> >
> >
> > I think this method could be fixed as
> > SequenceableCollection>>
> > collect: aBlock from: firstIndex to: lastIndex
> > "Refer to the comment in Collection|collect:."
> > | result |
> > result _ self species new: lastIndex - firstIndex + 1.
> > firstIndex to: lastIndex do: [:index | result at: index - firstIndex +
> > 1 put: (aBlock value: (self at: index))].
> > ^ result
> > (checked, too).
>
> Yep, that's a bug. The only code where it's currently used in the image
> always has firstIndex = 1.
I have posted a [FIX].
>
> But: Shouldn't the method better be named #from:to:collect: which would
> better fit into the other enumeration methods? Usually the block comes
> last ... If you agree, put out a changeset with your fix.
I don't agree at *this* time.
SequenceableCollection (there may be more in other classes) has one
other enumeration method
>>do:without:
(with 4 callers) without the main block as last argument and possibly
also
>>do: elementBlock separatedBy: separatorBlock
is questionable, because the 'main' block is the first argument.
So what about these methods?
Please keep in mind such methods as >>copyWithout: and that, if you look
for a >>do: method you currently find >>do:without: near by it, but you
wouldn't find near by it a method called >>without:do:.
I would like to hear other opinions regarding this topic, before
thinking of changing these methods (and their callers).
Greetings,
Stephan
>
> -- Bert
--
Stephan Rudlof (sr at evolgo.de)
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3
More information about the Squeak-dev
mailing list
|