Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-24 Thread Romain Francois
Thanks for these comments. I should alter the blog post or write some follow up. This was a weekend blog post that only benefited from a short time of research research. I’m glad people find it useful, but I’m sure a detailed documentation of the features from the authors would be more

Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-24 Thread Serguei Sokol
Le 24/09/2019 à 07:48, Gabriel Becker a écrit : Also, a small nitpick, R's internal mean function doesn't hit Dataptr, it hits either INTEGER_ELT (which really should probably be a ITERATE_BY_REGION) or ITERATE_BY_REGION. Even if it is not the main point of this thread, I was wondering if

Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-23 Thread Gabriel Becker
Hi Bob, Thanks for sending around the link to that. It looks mostly right and looks like a useful onramp. There are a few things to watch out for though (I've cc'ed Romain so he's aware of these comments). @romain I hope you taake the following comments as they are intended, as help rather than

Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-23 Thread Bob Rudis
Not sure if you're using just C++ or Rcpp for C++ access but https://purrple.cat/blog/2018/10/14/altrep-and-cpp/ has some tips on using C++ w/ALTREP. > On Sep 23, 2019, at 3:17 PM, Wang Jiefei wrote: > > Sorry for post a lot of things, for the first part of code, I copied my C++ > iter macro

Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-23 Thread Wang Jiefei
Sorry for post a lot of things, for the first part of code, I copied my C++ iter macro by mistake(and you can see an explicit type casting). Here is the macro definition from R_exts/Itermacros.h #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \

Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-23 Thread Wang Jiefei
Hi Gabriel, I have tried the macro and found a small issue, it seems like the macro is written in C and does an implicit type conversion(const void * to const int *), see below. While it is allowed in C, C++ seems not happy with it. Is it possible to add an explicit type casting so that it can be

[Rd] What is the best way to loop over an ALTREP vector?

2019-08-27 Thread Wang Jiefei
Hi devel team, I'm working on C/C++ level ALTREP compatibility for a package. The package previously used pointers to access the data of a SEXP, so it would not work for some ALTREP objects which do not have a pointer. I plan to rewrite the code and use functions like get_elt, get_region, and