[ENH] RBRelatedPatches [sm]
Richard A. O'Keefe
ok at cs.otago.ac.nz
Wed Sep 17 07:12:56 UTC 2003
Concerning
aCollection ifEmpty: [ ] ifNotEmpty: [ ]
why would I use that rather than
aCollection isEmpty ifTrue: [ ] ifFalse: [ ]
I know it's a touch more intention-revealing, but only a touch,
and the isEmpty ifTrue:ifFalse: version is inlined, while the
ifEmpty:ifNotEmpty: version isn't.
ifEmpty: [ ] ifNotEmptyDo: [ :v | ]
I _can_ see why to use that, when the collection would otherwise
not be available in an argument or temporary. While I'm not a bigot
about the Law of Demeter, it does make me a bit uneasy about this.
Sticking with
v := ...
v isEmpty ifTrue: [ ] ifFalse: [...use v...].
means a smaller cognitive load, and as a bear of very little brain
I value small cognitive loads.
Note: this is NOT opposition to these methods being added. As far as
I can tell that wouldn't break anything, and the names _are_ intention-
revealing. It's a simple question about whether it's better to stick
to a small number of #if* forms or to let them multiply and ignore the
inlining issue.
More information about the Squeak-dev
mailing list
|