[Rd] Request: Suggestions for "good teaching" packages, esp. with C code

Ken.Williams at thomsonreuters.com Ken.Williams at thomsonreuters.com
Tue Feb 15 23:43:16 CET 2011


On 2/15/11 4:35 PM, "Gabor Grothendieck" <ggrothendieck at gmail.com> wrote:

>I think the real good programming practice is to have a single point
>of exit at the bottom.

I disagree, it can be extremely useful to exit early from a function.  It
can also make the code much more clear by not having 95% of the body in a
huge else{} block.


>If that is how you program all your functions
>then you don't need to explicitly put a return in since it always
>returns from the bottom anyways and the return would just clutter your
>code.

For someone else reading your code, they wouldn't know that you always do
this unless they're very familiar with your coding style.  Even then, it
needs to be manually checked by inspection because nobody sticks with the
"rule" 100% of the time, so it renders the benefit moot.

--
Ken Williams
Senior Research Scientist
Thomson Reuters
Phone: 651-848-7712
ken.williams at thomsonreuters.com
http://labs.thomsonreuters.com



More information about the R-devel mailing list