Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!cad!faustus From: faustus@cad.BERKELEY.EDU (Wayne A. Christopher) Newsgroups: net.lang.c Subject: Re: What should be added to C Message-ID: <450@cad.BERKELEY.EDU> Date: Wed, 28-May-86 18:23:39 EDT Article-I.D.: cad.450 Posted: Wed May 28 18:23:39 1986 Date-Received: Fri, 30-May-86 06:38:34 EDT References: <1462@mmintl.UUCP> <5498@alice.uUCp> <1497@mmintl.UUCP> Organization: CAD Group, U.C. Berkeley Lines: 67 In article <1497@mmintl.UUCP>, franka@mmintl.UUCP writes: > You would write: > > if (A) { > X > } andif (B) { > Y > } else { > Z > } > > This is equivalent to: > > if (!(A)) goto _Z; > X > if (B) { > Y > } else { > _Z: > Z > } It is also equivalent to: if (A) { X if (B) { Y } } if (!A || !B) Z } I think this looks cleaner, but in any case it isn't an often-encountered situation and the semantics aren't obvious. > To write more sophisticated macros. For example, one could write a copy > macro which would invoke strcpy in most cases, but a word copy routine to > copy an array of structures whose size is a multiple of a word. Such a > macro would be machine dependant -- this is exactly the reason for making it > a macro, instead of hard coding the calls. You can write arbitrarily large macros by putting backslashes at the end of lines. This is ugly but it works. > Confusing "=" and "==" in if statements is a common mistake. If "=" is not > a legal operator, this error becomes very rare. It's also an extra character to type. If you are prone to this sort of error, just run your code through grep if | grep = | grep -v == ... > >The trouble with adding new features to C is that there is a very > >strong incentive not to use them. After all, any program that > >uses some new feature is only going to run on machines that support > >that feature. I don't think I'm going to be using only one compiler > >for the rest of my life and would like to avoid changing my code > >every time the environment hiccups. > > This is the whole point of having a standard. It gives you some assurance > that compilers which use the features will be available. If the standard has all the things you enumerate, not many people will follow it and it will be worse than no standard at all. Wayne