Posted by
Chris Muller-3 on
Aug 14, 2018; 7:48pm
URL: https://forum.world.st/The-Inbox-Tools-LM-828-mcz-tp5082873p5082968.html
Hi Eliot,
On Mon, Aug 13, 2018 at 9:59 PM, Eliot Miranda <
[hidden email]> wrote:
> Hi,
>
> regarding
>
> + obj := parents at: obj ifAbsent: [nil].
> - obj := parents at: obj ifAbsent: [].
>
>
> Please no. One must know that the empty block evaluates to nil. It is
> illiterate not to. So the verbosity is bad; it implies uncertainty (“does
> the empty block evaluate to nil? maybe not ‘cuz here it’s written
> explicitly”), it requires more typing, it’s ugly.
But the return value from the block is ^actually consumed^ by the
while condition, so making an explicit reference to nil greatly
improves readability. If the value were NOT consumed, then I would
agree that no return object should be specified, however I would
implore you never to write this code: []. Instead:
[ "always put an intention-revealing comment inside" ]
Why? Because emptiness is inherently ambiguous -- e.g., did the
programmer forget to fill that part in? Or was he intending to
actually "return nil". Talk about uncertainty!
I've always felt our code should appeal to the _broadest_ audience
possible, so that even those illiterate in Smalltalk could still read
it and follow it. It requires an expert Smalltalker and deep
consideration (and prioritization!) of the human <---> Smalltalk
"negotiation" to write code that is, all at once, terse, beautiful and
able be easily readable even to the broadest possible audience.
Best,
Chris