From pdalgd at gmail.com  Fri Mar 22 09:31:57 2013
From: pdalgd at gmail.com (peter dalgaard)
Date: Fri, 22 Mar 2013 09:31:57 +0100
Subject: [Rd] Deprecating partial matching in $.data.frame
In-Reply-To: <514BE4D6.105@fhcrc.org>
References: <A0DE2631-213D-4DB2-A952-5DBFA7A7F14C@gmail.com>
	<E66794E69CFDE04D9A70842786030B931B918849@PA-MBX04.na.tibco.com>
	<A3631670-5E8D-48DC-9868-8C9EE8852FE6@gmail.com>
	<CABdHhvHdHnOEyS+MKmwKTQpYp=zsfB84QDND-LRo2Sf4DXrRXA@mail.gmail.com>
	<514AC40E.2080808@gmail.com>
	<9966F1D2-A672-4017-B59D-C05BC86DB603@gmail.com>
	<514BE4D6.105@fhcrc.org>
Message-ID: <A60359C0-87E8-430A-B76A-1D800A5A00CB@gmail.com>


On Mar 22, 2013, at 05:57 , Herv? Pag?s wrote:

> Hi,
> 
> Maybe a compromise would be to just issue a warning without
> deprecating? That way people who want to do anova(fit1)$P can
> still do it. When working interactively, it's certainly convenient
> (serious code however should probably stay away from partial matching).

That's what it does. Issuing a warning when users do X is pretty much equivalent to deprecating X.

> 
> And so you keep the semantic consistent with lists because yes,
> consistency is important. data.frame inherits from list so any
> operation that works on a list is expected to work on a data.frame,
> preferably the same way (otherwise it will always be a BIG surprise
> to the user/programmer). For example if I have to maintain someone
> else code and see something like:
> 
>    bar <- x$bar
> 
> and I know that 'x' is a list that contains atomic vectors of the
> same length, I could have some good reasons to want to use a
> data.frame instead of a list. And I would assume it's safe to
> modify the code by adding the following line earlier in it:
> 
>   x <- as.data.frame(x)
> 
> But with the proposed change to $.data.frame, I cannot make this
> kind of assumption anymore...


No, but it's only a real problem if the component is not actually called "bar". You could make the same point for environments, but they never allowed partial matching:

> e <- as.environment(list(barbaric=666))
> e$bar
NULL
> e$barbaric
[1] 666




-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] Deprecating partial matching in $.data.frame
peter dalgaard