Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!sri-unix!jrv@mitre-bedford.ARPA From: jrv@mitre-bedford.ARPA Newsgroups: net.lang.c Subject: advice statement Message-ID: <12855@sri-arpa.UUCP> Date: Sun, 26-Aug-84 18:55:00 EDT Article-I.D.: sri-arpa.12855 Posted: Sun Aug 26 18:55:00 1984 Date-Received: Thu, 30-Aug-84 19:48:59 EDT Lines: 34 I'd like to see a statement added to C to let the programmer declare the fraction of the time he expects an expression to be nonzero (true). A typical use might be: root=x/2; next_root=x; while(root!=next_root \.90) {root=next_root; next_root=(root+x/root)/2.; } ...where the programmer expects the completion test to fail 90% of the time. (By the way, I have no particular love for this syntax.) This feature would have the following uses: (1) The COMPILER, when trying to optimize loops, normally tries to take expensive operations out of a loop and move them before or after the loop ("strength reduction"). If the loop is hardly ever executed, this is a bad idea. The programmer ought to be able to advise the compiler of this situation. (2) The PROGRAM TESTER (whether human or software) could check the correctness of the programmer's guess and warn him if it were out of line. The particular value 1 (always true) could signal an invariant for which a proof might be attempted. (3) A READER of the program, on the first pass, could follow only the "most of the time" paths, thereby getting an overview of the program without getting confused by such things as error handling and garbage collecting. Does anybody else think this is a good idea? - Jim Van Zandt