From jmc at r-project.org  Tue Aug 13 22:34:56 2013
From: jmc at r-project.org (John Chambers)
Date: Tue, 13 Aug 2013 13:34:56 -0700
Subject: [Rd] Multiple return values / bug in rpart?
In-Reply-To: <alpine.DEB.2.02.1308131341320.28684@luke-Latitude>
References: <mailman.15.1376388008.32611.r-devel@r-project.org>
	<520A2C8B.4080901@mayo.edu> <520A2DA4.9070600@stats.ox.ac.uk>
	<520A4FD9.2010701@gmail.com>
	<alpine.DEB.2.02.1308131341320.28684@luke-Latitude>
Message-ID: <520A9870.8090907@r-project.org>

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.

   John


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.
>
> 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
>>
>



[Rd] Multiple return values / bug in rpart?
John Chambers