S4SXP type vs S4 object bit?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

S4SXP type vs S4 object bit?

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 the S4-bit and object type ever disagree for S4
objects?  I know that one can set the bit manually in C; are there any
practical applications for doing so?

Thank you
Travers

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: S4SXP type vs S4 object bit?

R devel mailing list
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 not derive from another basic type.

Michael

On Tue, Oct 22, 2019 at 1:28 AM Travers Ching <[hidden email]> wrote:

>
> 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 the S4-bit and object type ever disagree for S4
> objects?  I know that one can set the bit manually in C; are there any
> practical applications for doing so?
>
> Thank you
> Travers
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



--
Michael Lawrence
Scientist, Bioinformatics and Computational Biology
Genentech, A Member of the Roche Group
Office +1 (650) 225-7760
[hidden email]

Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: S4SXP type vs S4 object bit?

Wang Jiefei
In reply to this post by Travers Ching
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 framework: If one
class inherits the integer class, what should R do to make all the integer
related functions compatible with the new class at C level?

Best,
Jiefei

On Tue, Oct 22, 2019 at 4:28 AM Travers Ching <[hidden email]> wrote:

> 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 the S4-bit and object type ever disagree for S4
> objects?  I know that one can set the bit manually in C; are there any
> practical applications for doing so?
>
> Thank you
> Travers
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: S4SXP type vs S4 object bit?

Travers Ching
Thanks you Jiefei and Michael!

Travers

On Tue, Oct 22, 2019 at 8:14 AM Wang Jiefei <[hidden email]> 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 from any class, it will be an S4SXP. You
> can think about this question from the object-oriented framework: If one
> class inherits the integer class, what should R do to make all the integer
> related functions compatible with the new class at C level?
>
> Best,
> Jiefei
>
> On Tue, Oct 22, 2019 at 4:28 AM Travers Ching <[hidden email]> wrote:
>
>> 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 the S4-bit and object type ever disagree for S4
>> objects?  I know that one can set the bit manually in C; are there any
>> practical applications for doing so?
>>
>> Thank you
>> Travers
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel