Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Writing readable code Message-ID: <6051@brl-smoke.ARPA> Date: Fri, 3-Jul-87 22:58:34 EDT Article-I.D.: brl-smok.6051 Posted: Fri Jul 3 22:58:34 1987 Date-Received: Sun, 5-Jul-87 00:17:20 EDT References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <13008@topaz.rutgers.edu> <1571@sfsup.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 17 In article <1571@sfsup.UUCP> mpl@sfsup.UUCP writes: >If you read "The Elements of Programming Style" by Kernighan and Plauger (?) >(which you may or may not agree with), the authors suggest that a test for >< 0 is better than a test for -1, since a coding error could possibly cause >a function to return a value that is out of the legal range (> 0) but is not >the intended error value (-1). Some people (Dijkstra and Gries among them) no longer believe that this kind of "conservative" test is preferable to the exact test; they base this on what it takes to prove an implementation of an algorithm to be correct. >Not only that, but on many machines, a test for < 0 may be more >efficient than a test against a specific value. I doubt that the difference is detectable (remember, the code just made a system call!).