Do you ever program in C?

:>: -----Original Message-----
:>: From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
:>: Behalf Of John Gilmore
:>: Sent: Thursday, June 13, 2013 5:35 AM
:>: To: IBM-MAIN@LISTSERV.UA.EDU
:>: Subject: Re: DataPower XML Appliance and RACF
:>:
:>: About your example, it would also be my expectation that a C
:>: implementation of
:>:
:>: int bar = (7 > 3) ;
:>:
:>: would set bar equal to +1, since 7 is indeed greater than 3.
:>:

<snip>

:>:
:>: That said, and given the absence of a logical data type in C, the
:>: convention of returning -1 as a surrogate for the outcome false is
:>: appropriate if ugly.

FSVO false but not the "logical" one meaning not true.  int bar = (7<3);
will always set bar to 0, never to -1.

And C has had a logical type called _Bool for almost 15 years.

:>:
:>: It is, however, appropriate to distinguish between an outcome and a
:>: return code in many, indeed most contexts, i.e., to avoid confounding
:>: the true|false dichotomy with the success|fsailure dichotomy.  If a C
:>: function conducts a search for, say, an element of a character array
:>: that has the valuew '?' and does not find one, returning -1 to
:>: indicate this is in C appropriate.  If instead a C function attempts
:>: to open a file and does not succeed in doing so, returning -1 as an
:>: indicator that it failed  is not in my view enough.  In this case I
:>: would wish to have some further diagnostic information.

The reasons why a file was not opened can be system specific.  (It makes
sense for Windows to report "there is no such directory" but not for z/OS
when opening an MVS dataset.)  So the C language standard provides a
reasonably simple method than any implementation can use to report whatever
condition it sees fit.  In the case of opening a file, the C function
returns NULL (the POSIX function returns -1) and the standard error
interface "errno" can be set to a value to specify exactly what the problem
was.  If your system does not provide this extra information, blame whoever
wrote your library function, not the language.

:>: Opinions about such issues do differ; these differences are often as
:>: much visceral as intellectual; and it is my guess that we shall never
:>: agree about this and much else.

And some are just not factual.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to