[Rd] Multiple return values / bug in rpart?
jmc at r-project.org
Tue Aug 13 22:34:56 CEST 2013
And just in case anyone is curious about the history, return() with
multiple arguments was legal in S2 but the syntax in the blue book had
only return(expr), whether enforced or not in the code.
On 8/13/13 11:42 AM, luke-tierney at uiowa.edu wrote:
> Both codetools and the compiler should be checking for use of multiple
> args in return -- I'll look into adding that.
> 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
More information about the R-devel