In R version 2.15.2 (2012-10-26) i386-apple-darwin9.8.0/i386 (32-bit) I get
the following:

> a <- list(1)
> (a[[1]] <- a)
[[1]]
[[1]][[1]]
[1] 1

but

> a <- list(1)
> b <- a
> (a[[1]] <- a)
[[1]]
[1] 1

And similarly:

> a <- list(x=1)
> (a$x <- a)
$x
$x$x
[1] 1

but

> a <- list(x=1)
> b <- a
> (a$x <- a)
$x
[1] 1

In both cases the result of the first sequence is wrong. It's returning the
updated `a` rather than the RHS of the assignment. The second sequence in
both cases is correct; the assignment to `b` increments the NAMED value
causing the necessary copy to be made so the RHS is returned from the
assignment.

Would it be sufficient to add a check to do_subassign2_dflt
and do_subassign3_dflt that creates a duplicate of the LHS if the LHS & RHS
are the same object?

Justin

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to