Reasons for Lint rules

Dan Ingalls Dan at SqueakLand.org
Fri Feb 25 18:03:07 UTC 2005


"Frank Shearar" <Frank.Shearar at rnid.org.uk> wrote...
>It occurs to me that it'd be nice to see a rationale for the Lint rules. Like, say, in a balloon text when you hovered over the title of the rule in the SmallLint Results window.
>
>For instance, "Uses the result of an add: message" - why is it bad form to do so? I mean, OrderedCollection>>add: does in fact return the object you added.

Yes, but it *shouldn't*.  The only reason it does in Squeak is that this piece of poor style wasn't recognized until after the ST-80 release, it then got canonized by the ANSI standard and now, perfect or not, the standard is somewhat valuable to our participation in the larger Smalltalk community.

The reason it shouldn't do this is simply stylistic.  Methods tend to be either procedures (that cause some activity or state-altering effect) or functions (that return some useful new value).  Functional methods obviously requires the return of a significant result.  Procedural methods, so the style goes, simply return self.

Of course it is possible sometimes to do clever things by violating this convention.  For instance if at:put: returned the i-th element before the store, then swaps would be facilitated, especially where the access is very expensive.  However the general convention seems to appeal to most seasoned Smalltalkers, and that's how it go into Lint.  The *minute* we lose the ANSI fascination, I think we should clean up those methods.

	- Dan

PS:  You can probably tell, I've got something more important that I *should* be doing  ;-)



More information about the Squeak-dev mailing list