[squeak-dev] The defaullt implementation of isEmpty might do too much work

Eliot Miranda eliot.miranda at gmail.com
Mon Oct 24 18:56:17 UTC 2016


On Mon, Oct 24, 2016 at 1:31 AM, Bert Freudenberg <bert at freudenbergs.de>
wrote:

> On Monday, 24 October 2016, monty <monty2 at programmer.net> wrote:
>
>> Why not just make #size a subclassResponsibility or add abstract
>> superclasses for lazy or infinite collections that implement #isEmpty using
>> #do: and change #size to shouldNotImplement?
>>
>
> Because #do: is the only method required to be overridden by Collection
> subclasses. All other methods are implemented in terms of #do:.
>

+1


> So yes, if your Collection subclass has an optimized implementation for
> #isEmpty, then provide it. That is a small price to pay for making a class
> work optimally across different code bases.
>
> - Bert -
>
>
>
>


-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20161024/3684cd16/attachment.htm


More information about the Squeak-dev mailing list