[Rd] bindingIsLocked returns illogical logical
Seth Falcon
sfalcon at fhcrc.org
Mon May 15 18:28:31 CEST 2006
Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
> On Mon, 15 May 2006, Seth Falcon wrote:
>> Is it enough to check for NA_LOGICAL or should all NA_* values be
>> checked for? Is there an easier/better way to do this sort of check?
>
> NA_LOGICAL and NA_INTEGER are the same value, and only NA_LOGICAL
> should occur here.
Makes sense (I knew that NA_LOGICAL and NA_INTEGER are the same, but I
didn't know whether this was a convenience or to allow for them to be
different in the future).
> I used
>
> /* As from R 2.4.0 we check that the value is allowed. */
> INLINE_FUN SEXP ScalarLogical(int x)
> {
> SEXP ans = allocVector(LGLSXP, 1);
> if (x == NA_LOGICAL) INTEGER(ans)[0] = NA_LOGICAL;
> else INTEGER(ans)[0] = (x != 0);
> return ans;
> }
>
> mainly because its intentions are crystal clear.
Agreed. Thanks for fixing this so quickly and for the
reminders/answers regarding NA handling.
Best,
+ seth
More information about the R-devel
mailing list