Path: utzoo!utgpu!water!watmath!clyde!rutgers!rochester!bbn!husc6!linus!philabs!micomvax!ray From: ray@micomvax.UUCP (Ray Dunn) Newsgroups: comp.lang.c Subject: Re: = vs ==, and do 10 i = 1.3 Keywords: C, lint, checking Message-ID: <887@micomvax.UUCP> Date: 21 Jan 88 16:26:57 GMT References: <8971@ccicpg.UUCP> etc Reply-To: ray@micomvax.UUCP (Ray Dunn) Organization: ^ Lines: 39 Posted: Thu Jan 21 11:26:57 1988 In article <8971@ccicpg.UUCP> @ccicpg.UUCP (Nick Crossley) writes: >I too have often made the error of writing if (a = b) rather than if (a == b), >... So I wrote a program 'check' which checked the things lint did not ... >... >The third warns about :- > if (a); > stat1; >which is legal, but dubious, and which one of my co-workers wrote, and which >took me a good day of debugging to notice the extra semicolon!! Ah yes, and then there is, for example: fn1 ("paramstring 1", 57); fn2 ("paramstring 2", 23); for (i = 1; i < 100; i++); fn3 (argument, i); Which has TWICE taken me a similar time to find (You'd think I'd learn!) This leads me into the whole question of formatted and indented source, which I feel has some serious risks involved with it. Indentation is IGNORED by Lint and the compiler, but is superficially VERY significant to we visually oriented beings. Thus the occasional problem in spotting the above class of errors. Aren't we in a very similar situation here to the oft complained about "blanks are ignored problem" of Fortran, which played its part in the space craft lost "do 10 i = 1.3" (perhaps) myth? The best solution I have seen to date, is an intelligent editor (C+ mode extension to EMACS) which always *automatically* indents your line to the correct position by context. I have often had syntax errors and the above situation found at source entry time using this method. Perhaps the integrated development environments we are now seeing (e.g. Turbo-C etc) should pay more attention to this aspect of the environment? Ray Dunn. ..philabs!micomvax!ray