On 13/06/2013 8:35 PM, John Gilmore wrote:
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.

My favorite language is assembly language, but it is true that I among
statement-level languages I strongly prefer Pl/I to C.  C is, in my
view, a flawed toy programming language that now suffers grievously
from hypertrophy.   (It is also correct, as you conjectured, that the
low and high bounds of a PL/I array were classically limited only by
the inequality -2^31 <= L <= H <= +2^31 - 1, -2147483648 <= L <= H <=
+2147483647.)

Oh no, not another language flame war!

C has a *lot* of flaws but it's a sharp (and dangerous) tool. For a toy it's been pretty successful. The overwhelming majority of operating systems running production workloads today are written in C. The e-mail client you are using will almost certainly be written in C/C++. The device drivers running on your PC and the servers servicing your mail will be written in C/C++. According to tiobe it's the most popular programming language in use, however flawed their metrics may be. Like it or loath it it's probably the most successful programming language ever. It's also childs play to re-compile a C program 64-bit with no or minimal code change. The same certainly cannot be said of assembly language or PL/1.

Geez, why do I always take the bait!

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.

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.

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.

John Gilmore, Ashland, MA 01721 - USA

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

----------------------------------------------------------------------
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