From ggrothendieck at gmail.com  Sat Apr 21 20:18:50 2012
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sat, 21 Apr 2012 14:18:50 -0400
Subject: [Rd] Problem with args
In-Reply-To: <9B374D55-4AC3-423D-AB64-620693B69A7D@r-project.org>
References: <CAP01uR=U_Dy8hU3YV6DQJF5oG94rMs1K--m-2607E_5nkCAkSA@mail.gmail.com>
	<991E37E4-561E-4482-AAEB-3BF400FC14F2@r-project.org>
	<CAP01uRmGjG3CMegARah6O==2wYOu6vGX1MRr5+-7H0SuwVuarQ@mail.gmail.com>
	<9B374D55-4AC3-423D-AB64-620693B69A7D@r-project.org>
Message-ID: <CAP01uRk_UgVOkg5ULr7wsZd0-C64HRet+ewDadPBLuGbcyxx=w@mail.gmail.com>

On Sat, Apr 21, 2012 at 2:10 PM, Simon Urbanek
<simon.urbanek at r-project.org> wrote:
>
> On Apr 21, 2012, at 1:45 PM, Gabor Grothendieck wrote:
>
>> On Sat, Apr 21, 2012 at 1:38 PM, Simon Urbanek
>> <simon.urbanek at r-project.org> wrote:
>>>
>>> On Apr 21, 2012, at 1:03 PM, Gabor Grothendieck wrote:
>>>
>>>> args ought to check that its argument is a function:
>>>>
>>>>> max <- 3
>>>>> args(max)
>>>> NULL
>>>>
>>>> e.g.
>>>>
>>>>> args <- function(name) {
>>>> + ? ? name <- match.fun(name)
>>>> + ? ? base::args(name)
>>>> + }
>>>>> args(max)
>>>> function (..., na.rm = FALSE)
>>>> NULL
>>>>
>>>
>>> You may want to read the docs in the first place:
>>>
>>> Value:
>>> [...]
>>>
>>> ? ? 'NULL' in case of a non-function.
>>>
>>
>> My post wasn't about the return value -- it was about the fact that the function name can be masked. ?Try the example I posted. ?I also posted a solution.
>>
>
> You're passing a non-function (the value of 3) so, obviously you get NULL. I think you're confusing function calls with values. What you probably intended was
>

That's only a workaround but it does not address the problem that args
ought not to work that way.  args can gather all the information
needed to fetch the correct object but doesn't.  The second example
shows how it should work.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



[Rd] Problem with args
Gabor Grothendieck