[Rd] Multiple return values / bug in rpart?

luke-tierney at uiowa.edu luke-tierney at uiowa.edu
Tue Aug 13 20:42:36 CEST 2013


Both codetools and the compiler should be checking for use of multiple
args in return -- I'll look into adding that.

Best,

luke

On Tue, 13 Aug 2013, Duncan Murdoch wrote:

> On 13-08-13 8:59 AM, Prof Brian Ripley wrote:
>> On 13/08/2013 13:54, Terry Therneau wrote:
>>> I don't remember what rpartpl once did myself; as you point out it is a
>>> routine that is no longer used and should be removed.  I've cc'd Brian
>>> since he maintains the rpart code.
>>> 
>>> Long ago return() with multiple arguments was a legal shorthand for
>>> returning a list. This feature was depricated in Splus, I think even
>>> before R rose to prominence.  I vaguely remember a time when it's usage
>>> generated a warning.
>> 
>> Yes, usage generated a warning then an error, but not parsing.
>>
>>   > foo <- function() return(a=1, b=2)
>>   > foo()
>> Error in return(a = 1, b = 2) : multi-argument returns are not permitted
>> 
>>> The fact that I've never noticed this unused routine is somewhat
>>> embarrassing.  Perhaps I need a "not documented, never called" addition
>>> to R CMD check to help me along.
>> 
>> But you cannot know 'never called'.  This is callable by
>> rpart:::rpartpl() : it is also possible that functions in your namespace
>> are called via eval()ing expressions at R or C level.  (There are
>> examples around for which that is the only usage.)
>
> An approximation to "never called" is to run Rprof on your test code, and see 
> which functions are not mentioned.  I have a package under construction with 
> some students that can use this approach to identify which lines are never 
> seen while profiling the test code.
>
> Duncan Murdoch
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-devel mailing list