[squeak-dev] Re: [Newbies] Two questions about Smalltalk language design

Andreas.Raab andreas.raab at gmx.de
Thu Jan 3 12:37:23 UTC 2013


Casey Ransberger-2 wrote
> Worth pointing out (at least I *think*) there's little real value in
> returning nil by default, even though it makes a certain amount of
> visceral sense. 

There are two major reasons why returning nil by default makes sense:
* It is consistent with what people /see/ when looking at the code, i.e., if
a method doesn't return anything /visibly/ it shouldn't silently do
something completely different. This makes the language easier to learn
since there are fewer special cases to know about.
* It prevents implicitly leaking authority. This of course is only relevant
for people who care about security aspects but in this case returning self
is really the wrong choice (so is evaluating the last statement of blocks to
be the block return value; block return should be explicit too).

Cheers,
  - Andreas




--
View this message in context: http://forum.world.st/Re-Newbies-Two-questions-about-Smalltalk-language-design-tp4660938p4661880.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.


More information about the Squeak-dev mailing list