Is there any way to check the class of an ALTREP?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there any way to check the class of an ALTREP?

Jiefei Wang
Hi all,

I would like to determine if an ALTREP object is from my package, I see
there is a function `ALTREP_CLASS` defined in RInternal.h but its return
value is neither a `R_altrep_class_t` object nor an STRSXP representing a
class name. I do not know how to correctly use it. Any suggestions?

Thanks,
Jiefei

        [[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: Is there any way to check the class of an ALTREP?

Benjamin Christoffersen
It seems as if you can you use the ALTREP macro as done in this
package: https://github.com/Jiefei-Wang/SharedObject/blob/804b6ac58c63a4bae95343ab43e8b1547b07ee6b/src/C_interface.cpp#L185

and in base R: https://github.com/wch/r-source/blob/54fbdca9d3fc63437d9e697f442d32732fb4f443/src/include/Rinlinedfuns.h#L118

The macro is defined here in Rinternals.h:
https://github.com/wch/r-source/blob/abb550c99b3927e5fc03d12f1a8e7593fddc04d2/src/include/Rinternals.h#L325

Den man. 19. okt. 2020 kl. 10.13 skrev Jiefei Wang <[hidden email]>:

>
> Hi all,
>
> I would like to determine if an ALTREP object is from my package, I see
> there is a function `ALTREP_CLASS` defined in RInternal.h but its return
> value is neither a `R_altrep_class_t` object nor an STRSXP representing a
> class name. I do not know how to correctly use it. Any suggestions?
>
> Thanks,
> Jiefei
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

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

Re: Is there any way to check the class of an ALTREP?

Dénes Tóth-2
Benjamin,

You happened to send a link which points to the OP's own package :) I
think Jiefei would like to know how one can "officially" determine if an
arbitrary ALTERP object belongs to a class that he owns.

Regards,
Denes


On 10/19/20 10:22 AM, Benjamin Christoffersen wrote:

> It seems as if you can you use the ALTREP macro as done in this
> package: https://github.com/Jiefei-Wang/SharedObject/blob/804b6ac58c63a4bae95343ab43e8b1547b07ee6b/src/C_interface.cpp#L185
>
> and in base R: https://github.com/wch/r-source/blob/54fbdca9d3fc63437d9e697f442d32732fb4f443/src/include/Rinlinedfuns.h#L118
>
> The macro is defined here in Rinternals.h:
> https://github.com/wch/r-source/blob/abb550c99b3927e5fc03d12f1a8e7593fddc04d2/src/include/Rinternals.h#L325
>
> Den man. 19. okt. 2020 kl. 10.13 skrev Jiefei Wang <[hidden email]>:
>>
>> Hi all,
>>
>> I would like to determine if an ALTREP object is from my package, I see
>> there is a function `ALTREP_CLASS` defined in RInternal.h but its return
>> value is neither a `R_altrep_class_t` object nor an STRSXP representing a
>> class name. I do not know how to correctly use it. Any suggestions?
>>
>> Thanks,
>> Jiefei
>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

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

Re: Is there any way to check the class of an ALTREP?

Benjamin Christoffersen
> You happened to send a link which points to the OP's own package :) I
> think Jiefei would like to know how one can "officially" determine if an
> arbitrary ALTERP object belongs to a class that he owns.
Argh, I am sorry! I did not notice that. My best bet for what I
thought the question was is section 1.1.2 of R Internals where they
note that: `unsigned int alt : 1; /* is this an ALTREP object? */`

This is also what the ALTREP macro checks. However, I also did not
notice the "... if an ALTREP object is from my package" part. I am
sorry.

Sincerely Yours,
Benjamin

Den man. 19. okt. 2020 kl. 11.25 skrev Dénes Tóth <[hidden email]>:

>
> Benjamin,
>
> You happened to send a link which points to the OP's own package :) I
> think Jiefei would like to know how one can "officially" determine if an
> arbitrary ALTERP object belongs to a class that he owns.
>
> Regards,
> Denes
>
>
> On 10/19/20 10:22 AM, Benjamin Christoffersen wrote:
> > It seems as if you can you use the ALTREP macro as done in this
> > package: https://github.com/Jiefei-Wang/SharedObject/blob/804b6ac58c63a4bae95343ab43e8b1547b07ee6b/src/C_interface.cpp#L185
> >
> > and in base R: https://github.com/wch/r-source/blob/54fbdca9d3fc63437d9e697f442d32732fb4f443/src/include/Rinlinedfuns.h#L118
> >
> > The macro is defined here in Rinternals.h:
> > https://github.com/wch/r-source/blob/abb550c99b3927e5fc03d12f1a8e7593fddc04d2/src/include/Rinternals.h#L325
> >
> > Den man. 19. okt. 2020 kl. 10.13 skrev Jiefei Wang <[hidden email]>:
> >>
> >> Hi all,
> >>
> >> I would like to determine if an ALTREP object is from my package, I see
> >> there is a function `ALTREP_CLASS` defined in RInternal.h but its return
> >> value is neither a `R_altrep_class_t` object nor an STRSXP representing a
> >> class name. I do not know how to correctly use it. Any suggestions?
> >>
> >> Thanks,
> >> Jiefei
> >>
> >>          [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >

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

Re: Is there any way to check the class of an ALTREP?

Jiefei Wang
Thank Denes for the clarification, glad to see my package got one citation
from my own question:) Also, thank Benjamin
for sending many useful documents.

Actually, the question is related to the SharedObject package that Benjamin
has pointed to. I wanna
avoid sharing an object that has already been shared, so I need to check
whether an object is an ALTREP
that is defined in my package. Since the ALTREP definition involves an `
R_altrep_class_t` object and a
 class name, I will expect to see a method defined in R to retrieve such
information. I hope this can clarify my question.

Best,
Jiefei

On Mon, Oct 19, 2020 at 5:38 PM Benjamin Christoffersen <[hidden email]>
wrote:

> > You happened to send a link which points to the OP's own package :) I
> > think Jiefei would like to know how one can "officially" determine if an
> > arbitrary ALTERP object belongs to a class that he owns.
> Argh, I am sorry! I did not notice that. My best bet for what I
> thought the question was is section 1.1.2 of R Internals where they
> note that: `unsigned int alt : 1; /* is this an ALTREP object? */`
>
> This is also what the ALTREP macro checks. However, I also did not
> notice the "... if an ALTREP object is from my package" part. I am
> sorry.
>
> Sincerely Yours,
> Benjamin
>
> Den man. 19. okt. 2020 kl. 11.25 skrev Dénes Tóth <[hidden email]
> >:
> >
> > Benjamin,
> >
> > You happened to send a link which points to the OP's own package :) I
> > think Jiefei would like to know how one can "officially" determine if an
> > arbitrary ALTERP object belongs to a class that he owns.
> >
> > Regards,
> > Denes
> >
> >
> > On 10/19/20 10:22 AM, Benjamin Christoffersen wrote:
> > > It seems as if you can you use the ALTREP macro as done in this
> > > package:
> https://github.com/Jiefei-Wang/SharedObject/blob/804b6ac58c63a4bae95343ab43e8b1547b07ee6b/src/C_interface.cpp#L185
> > >
> > > and in base R:
> https://github.com/wch/r-source/blob/54fbdca9d3fc63437d9e697f442d32732fb4f443/src/include/Rinlinedfuns.h#L118
> > >
> > > The macro is defined here in Rinternals.h:
> > >
> https://github.com/wch/r-source/blob/abb550c99b3927e5fc03d12f1a8e7593fddc04d2/src/include/Rinternals.h#L325
> > >
> > > Den man. 19. okt. 2020 kl. 10.13 skrev Jiefei Wang <[hidden email]
> >:
> > >>
> > >> Hi all,
> > >>
> > >> I would like to determine if an ALTREP object is from my package, I
> see
> > >> there is a function `ALTREP_CLASS` defined in RInternal.h but its
> return
> > >> value is neither a `R_altrep_class_t` object nor an STRSXP
> representing a
> > >> class name. I do not know how to correctly use it. Any suggestions?
> > >>
> > >> Thanks,
> > >> Jiefei
> > >>
> > >>          [[alternative HTML version deleted]]
> > >>
> > >> ______________________________________________
> > >> [hidden email] mailing list
> > >> https://stat.ethz.ch/mailman/listinfo/r-devel
> > >
> > > ______________________________________________
> > > [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: Is there any way to check the class of an ALTREP?

Jiefei Wang
Hi all,

By looking at the implementation of R's wrapper. I found a function `
R_altrep_inherits` that can check whether an object belongs to an ALTREP
class. Even though it is a little different from what I am looking for, but
it should be satisfactory for my purpose. I will suspect there is no such
function in R to get the class of an ALTREP object for the SEXP struct is
very compact and this less-important information might not be stored when
an ALTREP object is created.

Best,
Jiefei

On Mon, Oct 19, 2020 at 8:37 PM Jiefei Wang <[hidden email]> wrote:

> Thank Denes for the clarification, glad to see my package got one citation
> from my own question:) Also, thank Benjamin
> for sending many useful documents.
>
> Actually, the question is related to the SharedObject package that
> Benjamin has pointed to. I wanna
> avoid sharing an object that has already been shared, so I need to check
> whether an object is an ALTREP
> that is defined in my package. Since the ALTREP definition involves an `
> R_altrep_class_t` object and a
>  class name, I will expect to see a method defined in R to retrieve such
> information. I hope this can clarify my question.
>
> Best,
> Jiefei
>
> On Mon, Oct 19, 2020 at 5:38 PM Benjamin Christoffersen <
> [hidden email]> wrote:
>
>> > You happened to send a link which points to the OP's own package :) I
>> > think Jiefei would like to know how one can "officially" determine if an
>> > arbitrary ALTERP object belongs to a class that he owns.
>> Argh, I am sorry! I did not notice that. My best bet for what I
>> thought the question was is section 1.1.2 of R Internals where they
>> note that: `unsigned int alt : 1; /* is this an ALTREP object? */`
>>
>> This is also what the ALTREP macro checks. However, I also did not
>> notice the "... if an ALTREP object is from my package" part. I am
>> sorry.
>>
>> Sincerely Yours,
>> Benjamin
>>
>> Den man. 19. okt. 2020 kl. 11.25 skrev Dénes Tóth <[hidden email]
>> >:
>> >
>> > Benjamin,
>> >
>> > You happened to send a link which points to the OP's own package :) I
>> > think Jiefei would like to know how one can "officially" determine if an
>> > arbitrary ALTERP object belongs to a class that he owns.
>> >
>> > Regards,
>> > Denes
>> >
>> >
>> > On 10/19/20 10:22 AM, Benjamin Christoffersen wrote:
>> > > It seems as if you can you use the ALTREP macro as done in this
>> > > package:
>> https://github.com/Jiefei-Wang/SharedObject/blob/804b6ac58c63a4bae95343ab43e8b1547b07ee6b/src/C_interface.cpp#L185
>> > >
>> > > and in base R:
>> https://github.com/wch/r-source/blob/54fbdca9d3fc63437d9e697f442d32732fb4f443/src/include/Rinlinedfuns.h#L118
>> > >
>> > > The macro is defined here in Rinternals.h:
>> > >
>> https://github.com/wch/r-source/blob/abb550c99b3927e5fc03d12f1a8e7593fddc04d2/src/include/Rinternals.h#L325
>> > >
>> > > Den man. 19. okt. 2020 kl. 10.13 skrev Jiefei Wang <[hidden email]
>> >:
>> > >>
>> > >> Hi all,
>> > >>
>> > >> I would like to determine if an ALTREP object is from my package, I
>> see
>> > >> there is a function `ALTREP_CLASS` defined in RInternal.h but its
>> return
>> > >> value is neither a `R_altrep_class_t` object nor an STRSXP
>> representing a
>> > >> class name. I do not know how to correctly use it. Any suggestions?
>> > >>
>> > >> Thanks,
>> > >> Jiefei
>> > >>
>> > >>          [[alternative HTML version deleted]]
>> > >>
>> > >> ______________________________________________
>> > >> [hidden email] mailing list
>> > >> https://stat.ethz.ch/mailman/listinfo/r-devel
>> > >
>> > > ______________________________________________
>> > > [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