On Tue, 11 Jul 2006, Martin Morgan wrote:
> This is because RObjToCPtr is not quite careful enough with NAMED,
> rather than an issue with as.XXX
But DUP=FALSE is documented to be dangerous for this very reason. It never
copies, and ?.C makes it clear that .C(,DUP=FALSE) can modify variables
th
This is because RObjToCPtr is not quite careful enough with NAMED,
rather than an issue with as.XXX
tmp.c: void tmp(double *x) { x[0]=1; return; }
> f <- function(x) x
> x <- 0
> .C("tmp", f(x), DUP=FALSE)
[[1]]
[1] 1
> x
[1] 1
> x <- 0
> y <- x
> .C("tmp", x, DUP=FALSE)
[[1]]
[1] 1
> y
[1] 1
On Tue, 11 Jul 2006, Prof Brian Ripley wrote:
> On Fri, 7 Jul 2006, Thomas Lumley wrote:
> > On Fri, 7 Jul 2006, Martin Morgan wrote:
[...]
> > > More generally, perhaps as.vector might not duplicate when mode(x) ==
> > > mode ?
> >
> > This isn't a trivial change, because mode(x)==mode does
On Tue, 11 Jul 2006, Thomas Lumley wrote:
> On Tue, 11 Jul 2006, Prof Brian Ripley wrote:
>
> > On Fri, 7 Jul 2006, Thomas Lumley wrote:
> >
> > > On Fri, 7 Jul 2006, Martin Morgan wrote:
> > >
> > > > sapply calls lapply as
> > > >
> > > >answer <- lapply(as.list(X), FUN, ...)
> > > >
> > >
On Tue, 11 Jul 2006, Prof Brian Ripley wrote:
> On Fri, 7 Jul 2006, Thomas Lumley wrote:
>
>> On Fri, 7 Jul 2006, Martin Morgan wrote:
>>
>>> sapply calls lapply as
>>>
>>>answer <- lapply(as.list(X), FUN, ...)
>>>
>>> which, when X is a list, causes X to be duplicated unnecessarily. The
>>> c
On Fri, 7 Jul 2006, Thomas Lumley wrote:
> On Fri, 7 Jul 2006, Martin Morgan wrote:
>
> > sapply calls lapply as
> >
> >answer <- lapply(as.list(X), FUN, ...)
> >
> > which, when X is a list, causes X to be duplicated unnecessarily. The
> > coercion is unnecessary for other mode(X) because in
On Fri, 7 Jul 2006, Martin Morgan wrote:
> sapply calls lapply as
>
>answer <- lapply(as.list(X), FUN, ...)
>
> which, when X is a list, causes X to be duplicated unnecessarily. The
> coercion is unnecessary for other mode(X) because in lapply we have
>
>if (!is.list(X)) X <- as.list(X)
T
sapply calls lapply as
answer <- lapply(as.list(X), FUN, ...)
which, when X is a list, causes X to be duplicated unnecessarily. The
coercion is unnecessary for other mode(X) because in lapply we have
if (!is.list(X)) X <- as.list(X)
More generally, perhaps as.vector might not duplicate