Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!crdgw1!sungod!davidsen From: davidsen@sungod.crd.ge.com (William Davidsen) Newsgroups: comp.lang.c Subject: Feature for the next C version Message-ID: <1389@crdgw1.crd.ge.com> Date: 28 Jul 89 18:58:14 GMT References: <55480@tut.cis.ohio-state.edu> <1989Jul20.152935.14872@utzoo.uucp> <67@motto.UUCP> <18764@mimsy.UUCP> Sender: news@crdgw1.crd.ge.com Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric Corp. R&D, Schenectady, NY Lines: 35 In article <18764@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: | Having a complete binary tree (which is a condition for heaps) means | shorter code paths. A plain binary tree will work, but if it is | unbalanced you will end up doing more comparisons than necessary. | (`Complete' means that if you number the nodes like this: | | 1 | 2 3 | 4 5 6 7 | 8 9 10 11 12 13 14 15 This brings up the one feature of FORTRAN which is missing and would be useful in C (and other structured languages)... the arithmetic IF. When doing tree searches and many kinds of sorts, you often have logic which looks something like this: if (a == b) { /* match found */ } else if (a < b) { /* search lower portion of the tree */ } else { /* search upper portion of the tree */ } While most compilers will get rid of common subexpressions and stuff in this case, the code generated rarely makes use of the repeated testing of flags set by one compare, and the code is not as readable as it might be. Some contruct which clearly shows what the user is trying to do would add to the readability, if not the speed, of the code. bill davidsen (davidsen@crdos1.crd.GE.COM) {uunet | philabs}!crdgw1!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me