From murdoch at stats.uwo.ca  Thu May 17 22:40:19 2007
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Thu, 17 May 2007 16:40:19 -0400
Subject: [Rd] RFC: adding an 'exact' argument to [[
In-Reply-To: <Pine.LNX.4.64.0705172039480.10304@gannet.stats.ox.ac.uk>
References: <m2irarh1mu.fsf@ziti.fhcrc.org>	<Pine.GSO.4.56.0705171150100.25965@durian.statsci.com>	<m2fy5vfe3x.fsf@ziti.fhcrc.org>
	<Pine.LNX.4.64.0705172039480.10304@gannet.stats.ox.ac.uk>
Message-ID: <464CBDB3.2060706@stats.uwo.ca>

On 5/17/2007 3:54 PM, Prof Brian Ripley wrote:
> On Thu, 17 May 2007, Seth Falcon wrote:
> 
>> Bill Dunlap <bill at insightful.com> writes:
>>> This sounds interesting.  Do you intend to leave the $
>>> operator alone, so it will continue to do partial
>>> matching?  I suspect that that is where the majority
>>> of partial matching for list names is done.
>>
>> The current proposal will not touch $.  I agree that most intentional
>> partial matching uses $ (hopefully only during interactive sessions).
>> The main benefit of the our proposed change is more reliable package
>> code.  For long lists and certain patterns of use, there are also
>> performance benefits:
>>
>>    > kk <- paste("abc", 1:(1e6), sep="")
>>    > vv = as.list(1:(1e6))
>>    > names(vv) = kk
>>
>>    > system.time(vv[["fooo", exact=FALSE]])
>>       user  system elapsed
>>      0.074   0.000   0.074
>>
>>    > system.time(vv[["fooo", exact=TRUE]])
>>       user  system elapsed
>>      0.042   0.000   0.042
>>
>>
>>> It might be nice to have an option that made x$partial warn so we
>>> would fix code that relied on partial matching, but that is lower
>>> priority.
>>
>> I think that could be useful as well.  To digress a bit further in
>> discussing $... I think the argument that partial matching is
>> desirable because it saves typing during interactive sessions now has
>> a lot less weight.  The recent integration of the completion code
>> gives less typing and complete names.
> 
> There is a similar issue with argument partial matching.  Since we have 
> the source of R one can pretty easily build a version of R which does not 
> have the feature: I have been doing that in conjunction with 'codetools' 
> to do some checking.
> 
> In both cases there is traditional partial matching: seq(along=) or 
> seq(length=), and $fitted vs $fitted.values.  There are not many uses of 
> seq(along.with=) about and vastly more of seq(along=) (although in R using 
> seq_along() is preferable): even in some packages which do use 
> seq(along.with=) there are more instances of seq(along=).

Opinions, please:

In another thread I think we have agreement to add an extra arg to the 
vignette() function to limit it to attached packages.  By analogy with 
other similar functions, the arg would be named all.available.  However, 
I suspect most users would abbreviate that to just "all".

Should I name it "all.available" for consistency, or "all" in 
anticipation of a day when exact argument matching will be required?

Duncan Murdoch



[Rd] RFC: adding an 'exact' argument to [[
Duncan Murdoch