[datatable-help] Copy on assign broken in some cases

Matthew Dowle mdowle at mdowle.plus.com
Tue Nov 1 03:37:15 CET 2011


On Fri, 2011-10-28 at 17:59 -0700, Muhammad Waliji wrote:
> On Fri, Oct 28, 2011 at 5:57 PM, Matthew Dowle
> <mdowle at mdowle.plus.com> wrote:
>         On Fri, 2011-10-28 at 17:42 -0700, Muhammad Waliji wrote:
>         > On Fri, Oct 28, 2011 at 5:32 PM, Matthew Dowle
>         > <mdowle at mdowle.plus.com> wrote:
>         >
>         >         On Fri, 2011-10-28 at 09:52 -0700, Muhammad Waliji
>         wrote:
>         >         > >From the user's perspective, DT2 <- DT should
>         either be a
>         >         new copy or
>         >         > a new reference.  Anything in between is
>         confusing.
>         >
>         >
>         >         Agreed. With picky caveat: even in base it's not at
>         this point
>         >         the copy
>         >         is taken. It's later: copy-on-write. It's setkey
>         and := that
>         >         don't copy
>         >         on write, not the (earlier) <-.
>         >
>         >
>         > Hmm, I would prefer for these to have the same behavior.
>         
>         
>         Not sure I follow, please expand.
> 
> 
> I would like for DT[, x := foo] and DT$x <- foo to have the same
> behavior.  i.e. if one preserves the reference, so should the other.
>  

Agreed, I would too (at least I did to start with). However, it seems a
base R thing that <- copies via `*tmp*` and isn't possible to make it
work by reference.  See the (long) thread on r-devel here :

http://r.789695.n4.nabble.com/speeding-up-perception-tp3640920p3640920.html 

I'm pretty happy with :=, honestly. It's nice that <-, <<- and := all do
different and useful things within j. Changes to the meaning of [<-
might not have been backwards compatible, so := provides without
forcing.

Matthew





More information about the datatable-help mailing list