Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site reed.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!whuxl!houxm!vax135!cornell!uw-beaver!tektronix!reed!alexis From: alexis@reed.UUCP (Alexis Dimitriadis) Newsgroups: net.lang.c Subject: Re: C bites Dog! Message-ID: <1835@reed.UUCP> Date: Sun, 25-Aug-85 01:25:22 EDT Article-I.D.: reed.1835 Posted: Sun Aug 25 01:25:22 1985 Date-Received: Tue, 27-Aug-85 06:47:09 EDT References: <872@brl-tgr.ARPA> Reply-To: alexis@reed.UUCP (Alexis Dimitriadis) Organization: Reed College, Portland, Oregon Lines: 70 Summary: > > > > if (sv > score); <----- note extraneous semi-colon > > > > score = sv; > > ICK ICK ICK! I hate languages that do that. Ever considered using "cb" as a > > debugging tool? I have an MS-DOS version if anyone wants it... > [...] What > would you do, compare the output of `cb' with the original? Takes > lots of time & can be visually overlooked. Here is an idea I've had on the back burner for while: How about a program that checks the formatting of the source code for consistency? - Take a C beautifier. - Modify the lexical analyzer so it passes the amount of indentation preceding the line each input statement is on. - Now for each statement, check the _relative_ indentation. A normal statement should be indented exactly as far as the previous statement; the subordinate part of an "if" or a loop should be further indented, or be on the same line; lines that contain continuation of an expression can start anywhere, and do not affect the expected indent; etc. - If the input disagrees, give a diagnostic. This should catch things like if (tv.set == junk); turn(off); or even while (cat == away) mice(dance); cheese--; since the "while" should be aligned with the "cheese". Of course, it would be powerless with if (procter & gamble); chips++; unless you put in a rule about multiple equal-level statements on the same line, which would create problems with macro expansion, etc. Now I haven't started work on this yet, (first I finish my thesis), but it seems it could be made to work consistently, and without a lot of false alarms. However, a friend who may know better disagrees. Are there really impossible obstacles to the task? I know the lexical analyzer would have to keep track of the offset, and probably line number, of every token, but that's no big deal. Could it cope with the thousands of indenting styles? I think the test is general anough to cope with anything. Since there are so many places braces can be, they could be just ingored. Is it a pipe dream? Has it been done before? (If it has, it must be a well kept secret!). What should I watch out for? Whose code would it gag on? If you have the answers to any of this, (or even some good questions), I would appreciate hearing from you. Finally, I apologize for the length of this, and please! none of the above condones of condemns any particular style of indenting, the subject has been trashed to death anyway. I have kept the results of the indenting style survey, I will mail them to anyone interested. Thanks for your attention, Alexis Dimitriadis PS. I have lost the name of the person who conducted the survey. If you still have the "other style" answers, could you send me a list? -- _______________________________________________ As soon as I get a full time job, the opinions expressed above will attach themselves to my employer, who will never be rid of them again. alexis @ reed ...teneron! \ ...seismo!ihnp4! - tektronix! - reed.UUCP ...decvax! /