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

Tobias Pape Das.Linux at gmx.de
Tue Oct 25 20:03:31 UTC 2016


On 25.10.2016, at 21:45, Chris Muller <asqueaker at gmail.com> wrote:

> Folks there is NO BASIS at the level of Collection for assuming that
> do: [ : each | ^
> false ] is faster than ^self size=0.  In fact, the proper assumption
> is the opposite -- that #size is the optimized method, not #do:.

I don't understand on what _either_ performance-assumption is grounded.
Since I've apparently not been around since the early years of either 
ST-80 or Squeak, can someone enlighten me here?

Both ways seem somewhat reasonable:
 `self size = 0` is simple, easy to understand on first sight and said here to be more expensive than
 `self do: [:ea |  ^false]`, which is clever[1], possibly needs a double-take (or comment), but has a certain appeal of wholeness[2].

Best regards
	-Tobias








[1]: sadly, cleverness in software typically is a drawback. 
[2]: I mean, the minimalism that is possible by just using/providing #do: somehow conveys closure/completeness


More information about the Squeak-dev mailing list