[Rd] Suggestion: mkString(NULL) should be NA
Jeroen Ooms
jeroen.ooms at stat.ucla.edu
Tue May 24 18:30:18 CEST 2016
On Tue, May 24, 2016 at 5:59 PM, Gabriel Becker <gmbecker at ucdavis.edu> wrote:
> Shouldn't Rf_mkString(NULL) return (the c-level equivalent of) character()
> rather than the NA_character_?
No. It should still be safe to assume that mkString() always returns a
character vector of exactly length one. Anything else could lead to
type errors.
> An empty string and NULL aren't the same.
Exactly! So if you pass in an empty C string, you get an empty R
string, and if you pass in a null pointer you get NA.
Rf_mkString(NULL) <--> NA
Rf_mkString("") <--> ""
There is no ambiguity, and much better than segfaulting.
More information about the R-devel
mailing list