[Rd] ScalarLogical and setAttrib

2014-11-01 Thread Radford Neal
> From: Jeroen Ooms > > It seems like ScalarLogical returns a singleton object, which is not > the case for ScalarInteger or ScalarReal. I am currently working > around this using duplicate(ScalarLogical(0)), but was quite surprised > by this behavior of ScalarLogical. > From: Hadley Wickham >

Re: [Rd] ScalarLogical and setAttrib

2014-11-01 Thread Hervé Pagès
Hi, The problem is better illustrated with: library(inline) test2 <- cfunction(body = ' SEXP success = PROTECT(ScalarLogical(0)); setAttrib(success, install("foo"), mkString("bar")); UNPROTECT(1); return success; ') test3 <- cfunction(body = ' SEXP success = PROTECT(S

Re: [Rd] ScalarLogical and setAttrib

2014-11-01 Thread Hervé Pagès
Hi, The problem is better illustrated with: library(inline) test2 <- cfunction(body = ' SEXP success = PROTECT(ScalarLogical(0)); setAttrib(success, install("foo"), mkString("bar")); UNPROTECT(1); return success; ') test3 <- cfunction(body = ' SEXP success = PROTECT(S

Re: [Rd] ScalarLogical and setAttrib

2014-11-01 Thread Hadley Wickham
I believe this is by design (and changed relatively recently). FALSE and TRUE are singletons, like NULL. Hadley. On Friday, October 31, 2014, Jeroen Ooms wrote: > Is it expected that attributes set on a LGLSXP created by > ScalarLogical will apply to all future objects created by > ScalarLogica

[Rd] ScalarLogical and setAttrib

2014-10-31 Thread Jeroen Ooms
Is it expected that attributes set on a LGLSXP created by ScalarLogical will apply to all future objects created by ScalarLogical as well? For example: the 'test1' function below returns FALSE and 'test2' returns FALSE with an attribute: library(inline) test1 <- cfunction(body = 'return Scalar