Skip to content

[Question] Return NA_character #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
artemklevtsov opened this issue Jul 13, 2020 · 1 comment
Closed

[Question] Return NA_character #45

artemklevtsov opened this issue Jul 13, 2020 · 1 comment

Comments

@artemklevtsov
Copy link

artemklevtsov commented Jul 13, 2020

What correct way to return NA_character?

> cpp_eval('cpp11::r_string(NA_STRING)')
[1] "NA"
> cpp_eval('cpp11::writable::strings(NA_STRING)')
[1] NA
> cpp_eval('cpp11::writable::strings({NA_STRING})')
[1] "NA"
> cpp_eval('cpp11::writable::strings({NA_STRING, "text"})')
[1] "NA"   "text"
@jimhester
Copy link
Member

Are you sure the above results are correct? The second and third results should always be equivalent, which is what I see with the current CRAN release.

library(cpp11)
cpp_eval('cpp11::r_string(NA_STRING)')
#> [1] "NA"
cpp_eval('cpp11::writable::strings(NA_STRING)')
#> [1] NA
cpp_eval('cpp11::writable::strings({NA_STRING})')
#> [1] NA
cpp_eval('cpp11::writable::strings({NA_STRING, "text"})')
#> [1] "NA"   "text"

Created on 2020-07-13 by the reprex package (v0.3.0)

As of e2e04cc all four of these examples should now be consistent.

library(cpp11)
cpp_eval('cpp11::r_string(NA_STRING)')
#> [1] NA
cpp_eval('cpp11::writable::strings(NA_STRING)')
#> [1] NA
cpp_eval('cpp11::writable::strings({NA_STRING})')
#> [1] NA
cpp_eval('cpp11::writable::strings({NA_STRING, "text"})')
#> [1] NA     "text"

Created on 2020-07-13 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants