<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 25, 2016 at 6:33 AM, monty <span dir="ltr">&lt;<a href="mailto:monty2@programmer.net" target="_blank">monty2@programmer.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Except #do: isn&#39;t the only method required to be overridden. #add: and #remove:ifAbsent: are also abstract.<br></blockquote><div><br></div><div>Only for extensible subclasses. These *can not* be implemented in terms of #do: so they have to be implemented in a subclass.</div><div><br></div><div>Collection provides a maximum of protocol with a minimum of methods required to be overridden.</div><div><br></div><div>This discussion is besides the point though. I was just pointing out that requiring #size or #isEmpty to be a subclass responsibility is not a good idea, because they can and should be implemented in terms of #do:. Whether #isEmpty should be implemented in terms of #size is a wholly different issue. </div><div><br></div><div>Chris has some valid points about historical performance trade-offs which are worth discussing.</div><div><br></div><div>My take is that if we don&#39;t know *anything* about the subclass, we have to assume that #size can be way more expensive than a single iteration of #do: (e.g. a linked list). So using #do: is the sensible default implementation for #isEmpty. If OTOH a subclass has a very expensive #do:, then it&#39;s reasonable to assume that it would avoid doing much work if it is in fact empty.</div><div><br></div><div>If a Collection subclass did rely on an implementation detail of its superclass performance-wise then this is unfortunate, but easy to fix by implementing #isEmpty in terms of #size. We shouldn&#39;t let that get in the way of making our base libraries more elegant.</div><div><br></div><div>- Bert -</div></div></div></div>