[R] STRING_PTR_RO compared to STRING_ELT

Tim Taylor t|m@t@y|or @end|ng |rom h|ddene|eph@nt@@co@uk
Mon Oct 5 22:53:53 CEST 2026


Thank you both for the explanations. Just the info I was after.

Cheers

Tim

> On 5 Oct 2026, at 20:40, Ivan Krylov <krylov.r00t using gmail.com> wrote:
> 
> В Mon, 05 Oct 2026 16:35:55 +0100
> "Tim Taylor" <tim.taylor using hiddenelephants.co.uk> пишет:
> 
>> Apart from different ergonomics is there anything worth being aware
>> of when using STRING_PTR_RO versus STRING_ELT for getting CHARSXP?
> 
> Iris Simmons gave an excellent explanation. The only thing left to note
> is that some ALTREP classes currently have STRING_ELT methods that
> return CHARSXPs not protected from garbage collection:
> 
> https://bugs.r-project.org/show_bug.cgi?id=19135
> https://github.com/gagolews/stringi/issues/354
> https://github.com/tidyverse/vroom/pull/638
> https://github.com/apache/arrow/issues/51198
> 
> If your code can be expected to process strings from vroom or arrow and
> you chose STRING_ELT (instead of STRING_PTR_RO which would materialise
> the vector), you may need to add some workarounds.
> 
> --
> Best regards,
> Ivan



More information about the R-help mailing list