From waku at idi.ntnu.no  Sun Mar 29 22:40:11 2009
From: waku at idi.ntnu.no (waku at idi.ntnu.no)
Date: Sun, 29 Mar 2009 22:40:11 +0200 (CEST)
Subject: [Rd] if does not covert raw to logical (PR#13630)
Message-ID: <20090329204012.04223282C76F@mail.pubhealth.ku.dk>

Full_Name: Wacek Kusnierczyk
Version: 2.8.0 and 2.10.0 r48242
OS: Ubuntu 8.04 Linux 32 bit
Submission from: (NULL) (80.202.30.36)


The following raises an error:

   if (as.raw(1)) 1
   # error: unimplemented type 'raw' in 'asLogical'

However, ?'if' says:

" 
Arguments:

    cond: A length-one logical vector that is not 'NA'. Conditions of
          length greater than one are accepted with a warning, but only
          the first element is used.  Other types are coerced to
          logical if possible, ignoring any class. 
"

and the help page does not mention raw type arguments to 'if' at all. 

The error above is in clear contradiction to the documentation.  This might be a
flaw in the documentation, but the following succeeds:

   ifelse(raw(1), 1, 0)
   # 1

which suggests that the error above is a bug (i.e., the implementation fails to
convert raw to logical).

The same problem involves 'while':

   while(as.raw(1)) break
   # error: unimplemented type 'raw' in 'asLogical'

Regards,
vQ



[Rd] if does not covert raw to logical (PR#13630)
waku at idi.ntnu.no