Marcus

the contract is important and should be explicit because if you do not check the same size then you may have
part of the computation done and not the rest.
So I would introduce new methods with explicit names telling that
    fuzzyWith:do:
or soemthing like that.

On 3/9/14 14:40, Marcus Denker wrote:
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
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

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








Reply via email to