[R] boolean SEXP interpretation upon function return
Jim Lemon
jim at bitwrit.com.au
Fri Aug 5 13:48:51 CEST 2011
On 08/05/2011 09:19 PM, Prof Brian Ripley wrote:
> On Fri, 5 Aug 2011, Duncan Murdoch wrote:
>
>> On 11-08-05 12:09 AM, Alexandre Aguiar wrote:
>>> Hi,
>>>
>>> When a function returns a SEXP of type LGLSXP (logical) to signal
>>> whether
>>> it succeeded or failed, how is it intrepreted? Is it like C where
>>> SUCCESS
>>> = 0 or other value?
>>
>> Usually TRUE is used to signal success. TRUE is non-zero.
>
> Strictly, TRUE is not numeric: it is coerced to 1 when coerced to a
> numeric value.
>
> If you are looking at C level at the SEXP: don't as the internal
> representation is just that: 'internal and subject to change'.
>
> There is no C convention to use 0 for success: that is a Unix convention
> for status values as returned by exit(), and even there the man page
> will advise you to use the symbol EXIT_SUCCESS. Other OSes do differ.
>
see p164 Kernighan & Ritchie.
Jim
More information about the R-help
mailing list