From wdunlap at tibco.com  Tue May 24 18:14:42 2016
From: wdunlap at tibco.com (William Dunlap)
Date: Tue, 24 May 2016 09:14:42 -0700
Subject: [Rd] Suggestion: mkString(NULL) should be NA
In-Reply-To: <CABFfbXu0LTrSy9Qq5mouq6fX=nN=NF9xshtM8Q9khYn3cWtEQw@mail.gmail.com>
References: <CABFfbXt7raZDRaGP+T=XWKeBZq8oh88FRh8+Xj7jFkf_VFspsA@mail.gmail.com>
	<CABFfbXu0LTrSy9Qq5mouq6fX=nN=NF9xshtM8Q9khYn3cWtEQw@mail.gmail.com>
Message-ID: <CAF8bMcYKiCUsy7xgmsWLRn6J7ZOHVfeZ1v+24tMDMZeO=xCPfQ@mail.gmail.com>

Why should Rf_mkString(NULL) produce NA_STRING instead of ""
(R_BlankString)?  I prefer that passing in a nil pointer would cause
an error instead, as the nil may arise by accident, perhaps a pointer
to freed memory, and I would like to be notified that my code is bad instead
of getting a random NA_STRING.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, May 24, 2016 at 8:42 AM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu>
wrote:

> On Thu, May 12, 2016 at 1:20 PM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu>
> wrote:
> > I would like to propose that Rf_mkString(NULL) and Rf_mkChar(NULL)
> > return NA rather than segfault.
>
> An example implementation: https://git.io/vroxm
>
> With this patch, mkChar(NULL), mkCharCE(NULL, ce) would return
> NA_STRING rather than segfault at strlen(NULL). This automatically
> fixes mkString(NULL) as well which wraps mkChar (See Rinlinedfuns.h).
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



[Rd] Suggestion: mkString(NULL) should be NA
William Dunlap