From murdoch.duncan at gmail.com  Tue Aug 13 17:25:13 2013
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Tue, 13 Aug 2013 11:25:13 -0400
Subject: [Rd] Multiple return values / bug in rpart?
In-Reply-To: <520A2DA4.9070600@stats.ox.ac.uk>
References: <mailman.15.1376388008.32611.r-devel@r-project.org>
	<520A2C8B.4080901@mayo.edu> <520A2DA4.9070600@stats.ox.ac.uk>
Message-ID: <520A4FD9.2010701@gmail.com>

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



[Rd] Multiple return values / bug in rpart?
Duncan Murdoch