[squeak-dev] The defaullt implementation of isEmpty might do
too much work
monty2 at programmer.net
Tue Oct 25 04:33:23 UTC 2016
Except #do: isn't the only method required to be overridden. #add: and #remove:ifAbsent: are also abstract.
> Sent: Monday, October 24, 2016 at 4:31 AM
> From: "Bert Freudenberg" <bert at freudenbergs.de>
> To: "The general-purpose Squeak developers list" <squeak-dev at lists.squeakfoundation.org>
> Subject: Re: [squeak-dev] The defaullt implementation of isEmpty might do too much work
> On Monday, 24 October 2016, monty <monty2 at programmer.net[mailto: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 -
More information about the Squeak-dev