[Rd] Unexpected behavior when using macro to loop over vector

2019-10-22 Thread Wang Jiefei
Hi all, I found an unexpected behavior when I was trying to use the macro defined in "R_ext/Itermacros.h" to loop over an atomic vector. Here is a minimum example: C++ code ``` #include "R_ext/Itermacros.h" #define GET_REGION_BUFSIZE 2 //Redefine the macro since C++ is not happy with the implici

Re: [Rd] S4SXP type vs S4 object bit?

2019-10-22 Thread Travers Ching
Thanks you Jiefei and Michael! Travers On Tue, Oct 22, 2019 at 8:14 AM Wang Jiefei wrote: > Hi Travers, > > Just an additional remarks to Michael's answer, if your S4 class inherits > from R's basic types, say integer, the resulting object will be an INTSXP. > If your S4 class does not inherit

Re: [Rd] S4SXP type vs S4 object bit?

2019-10-22 Thread Wang Jiefei
Hi Travers, Just an additional remarks to Michael's answer, if your S4 class inherits from R's basic types, say integer, the resulting object will be an INTSXP. If your S4 class does not inherit from any class, it will be an S4SXP. You can think about this question from the object-oriented framewo

Re: [Rd] S4SXP type vs S4 object bit?

2019-10-22 Thread Michael Lawrence via R-devel
Yes, any object of a class that derives from a basic type, like an atomic vector for example, will be of the basic SEXP type, with the S4 bit set. This means that a class can extend "integer" and objects of that class can be treated as any ordinary integer vector. S4SXP is only for objects that do

[Rd] S4SXP type vs S4 object bit?

2019-10-22 Thread Travers Ching
I'm trying to understand the R internals a bit better and reading over the documentation. I see that there is a bit related to whether an object is S4 (S4_OBJECT_MASK), and also the object type S4SXP (25). The documentation makes clear that these two things aren't the same. But in practice, will