2014-09-03 14:40 GMT+02:00 Marcus Denker <marcus.denker@inria.fr>:
with:do: on SequencableCollection checks that both collections have the same size (it raises an Error if not).

with: otherCollection do: twoArgBlock
� � "Evaluate twoArgBlock with corresponding elements from this collection and otherCollection."
� � otherCollection size = self size ifFalse: [self error: 'otherCollection must be the same size'].
� � 1 to: self size do:
� � � � [:index |
� � � � twoArgBlock value: (self at: index)
� � � � � � � � value: (otherCollection at: index)]

I think we should not do that:

1) it is slow

Are you sure about that one? The check is a constant cost disregarding the collection length, and, anyway, self size is reused just after that.
2) when the other is larger, is would work and just omit the rest�
3) if it is smaller, you will get an error anyway

I have a feeling I'm not in Pharo anymore, but in R instead ;)

Thierry

There are just three methods doing such a size check:

with:do:
with:collect:
reverseWith:do:
(the last one actually raises a� � � � �SizeMismatch exception, it is the sole user of that exception)

Is there a reason why this makes sense?

I added an issue with a slice to clean it up:

https://pharo.fogbugz.com/f/cases/13946/speed-up-with-do-by-not-checking-size

� � � � Marcus