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

Bert Freudenberg bert at freudenbergs.de
Mon Oct 24 08:31:22 UTC 2016


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:.

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 -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20161024/43efcbda/attachment.htm


More information about the Squeak-dev mailing list