From sfalcon at fhcrc.org  Thu May 17 21:24:02 2007
From: sfalcon at fhcrc.org (Seth Falcon)
Date: Thu, 17 May 2007 12:24:02 -0700
Subject: [Rd] RFC: adding an 'exact' argument to [[
In-Reply-To: <Pine.GSO.4.56.0705171150100.25965@durian.statsci.com> (Bill
	Dunlap's message of "Thu, 17 May 2007 11:54:45 -0700 (PDT)")
References: <m2irarh1mu.fsf@ziti.fhcrc.org>
	<Pine.GSO.4.56.0705171150100.25965@durian.statsci.com>
Message-ID: <m2fy5vfe3x.fsf@ziti.fhcrc.org>

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.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org



[Rd] RFC: adding an 'exact' argument to [[
Seth Falcon