From lionel at rstudio.com  Sat Apr 15 15:33:10 2017
From: lionel at rstudio.com (Lionel Henry)
Date: Sat, 15 Apr 2017 15:33:10 +0200
Subject: [Rd] potential bug in attribute handling for externalptr
In-Reply-To: <58F13ECE.8040009@stern.nyu.edu>
References: <58F13ECE.8040009@stern.nyu.edu>
Message-ID: <CAJf4E3rHfGuOfDBEwD6A-eMiF2wg7OaKB1-S=Tt=cytXGGnayw@mail.gmail.com>

This is expected behaviour, pointers are an uncopyable type, just like
environments:

env <- new.env()
env
#> <environment: 0x7fb6d4822e30>

structure(env, foo = "bar")
env
#> <environment: 0x7fb6d4822e30>
#> attr(,"foo")
#> [1] "bar"


On Fri, Apr 14, 2017 at 11:27 PM, Patrick Perry <pperry at stern.nyu.edu>
wrote:

> Is the following expected behavior?
>
> > mkext <- inline::cfunction(language="C", body='return
> R_MakeExternalPtr(NULL, install("tag"), R_NilValue);')
> > x <- mkext()
> > y <- x
> > attr(y, "foo") <- "bar"
> > attributes(x)
> $foo
> [1] "bar"
>
> I would expect that modifying y's attributes should not affect x.
>
> [Tested on R version 3.3.3 x86_64-apple-darwin16.4.0 (64-bit)]
>
> Thanks,
>
>
> Patrick
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



[Rd] potential bug in attribute handling for externalptr
Lionel Henry