From martin.becker at mx.uni-saarland.de  Wed Feb 16 13:31:20 2011
From: martin.becker at mx.uni-saarland.de (Martin Becker)
Date: Wed, 16 Feb 2011 13:31:20 +0100
Subject: [Rd] Request: Suggestions for "good teaching" packages,
 esp. with C code
In-Reply-To: <4D5AF4A8.50001@auckland.ac.nz>
References: <AANLkTikODppzk5=x7=TzVepH+aHuvaZUErf_0xQZ5ioX@mail.gmail.com>
	<4D5AF4A8.50001@auckland.ac.nz>
Message-ID: <4D5BC398.3050209@mx.uni-saarland.de>

On 15.02.2011 22:48, David Scott wrote:
> On 16/02/2011 7:04 a.m., Paul Johnson wrote:
>> ...
>>
>> 4. We don't want gratuitous use of "return" at the end of functions.
>> Why do people still do that?
>
> Well I for one (and Jeff as well it seems) think it is good 
> programming practice. It makes explicit what is being returned 
> eliminating the possibility of mistakes and provides clarity for 
> anyone reading the code.
>
> David Scott
>
>

AFAIR (but I am not sure, maybe some expert can comment on this), there 
is a difference between using return and not using return when R code is 
called from C-code via eval(). If my memory is correct, a return() 
statement (in the R code) would abort the C function (which is trying to 
evaluate the R code, e.g., the body of a function) as well, which is 
probably not intended. So, the use of return() in R code may be quite 
disadvantageous in certain situations.

Martin

-- 
Dr. Martin Becker
Statistics and Econometrics
Saarland University
Campus C3 1, Room 217
66123 Saarbruecken
Germany



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