[Rd] discussion of change in R 3.3.0 to [<-

Michael Lawrence lawrence.michael at gene.com
Tue May 17 16:09:46 CEST 2016


I was looking into making sub-assignment into atomic vectors work when the
value is an S4 object. The plan was to simply dispatch to an as.vector
method and proceed as normal.

Currently, if 'x' is a list, then any S4 'value' is first wrapped in a list.
One can rationalize this by thinking of the S4 object as a scalar and that
the corresponding vector type is a list. But other places in the base
package, like mapply(), treat S4 arguments as implicitly vector-like (to
work they need length and [[ methods).

I'm not sure it's justified to consider S4 objects as scalar, especially as
we increasingly use S4 to abstract access to external data sources and
other specialized implementations, like RLEs. One could argue that, in the
context of iteration and sub-assignment, there is an implicit declaration
that the S4 object is vector-like. If that holds, then the current behavior
with lists should be deprecated.

Another idea is to introduce a generic "isVectorLike()" that would default
to false but classes could have methods returning true. That is more
complicated though.

On Tue, May 17, 2016 at 6:43 AM, Richard Morey <richarddmorey at gmail.com>
wrote:

> In the NEWS for R 3.3.0 is this change:
>
>
>     * [<- with an S4 value into a list currently embeds the S4 object
>       into its own list such that the end result is roughly equivalent
>       to using [[<-.  That behavior is deprecated.  In the future, the
>       S4 value will be coerced to a list with as.list().
>
> I cannot find a discussion of this change anywhere. Can someone point
> me to a discussion of the reasons and/or implications?
>
> Best,
> Richard
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list