From sfalcon at fhcrc.org  Mon May 15 18:28:31 2006
From: sfalcon at fhcrc.org (Seth Falcon)
Date: Mon, 15 May 2006 09:28:31 -0700
Subject: [Rd] bindingIsLocked returns illogical logical
In-Reply-To: <Pine.LNX.4.64.0605151639280.29105@gannet.stats.ox.ac.uk> (Brian
	Ripley's message of "Mon, 15 May 2006 16:43:24 +0100 (BST)")
References: <6phody0ct9e.fsf@gopher3.fhcrc.org> <m2lkt3n64e.fsf@ziti.local>
	<Pine.LNX.4.64.0605150803070.8993@gannet.stats.ox.ac.uk>
	<m2ves7ia6j.fsf@ziti.local>
	<Pine.LNX.4.64.0605151639280.29105@gannet.stats.ox.ac.uk>
Message-ID: <m2zmhjgsls.fsf@ziti.local>

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



[Rd] bindingIsLocked returns illogical logical
Seth Falcon