Path: utzoo!mnetor!uunet!husc6!bbn!rochester!PT.CS.CMU.EDU!IUS1.CS.CMU.EDU!edw From: edw@IUS1.CS.CMU.EDU (Eddie Wyatt) Newsgroups: comp.lang.c Subject: == vs = Message-ID: <626@PT.CS.CMU.EDU> Date: 11 Jan 88 18:17:49 GMT Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 89 I got this letter that I thought I would public reply to. Received: from AMES-NAS.ARPA by IUS1.CS.CMU.EDU; 11 Jan 88 12:32:26 EST Received: Mon, 11 Jan 88 09:30:17 PST by ames-nas.arpa (5.51/1.2) Date: Mon, 11 Jan 88 09:30:17 PST From: Michael S. Fischbein Message-Id: <8801111730.AA18470@ames-nas.arpa> To: edw@IUS1.CS.CMU.EDU Subject: Re: (So-Called) ANSI C Newsgroups: comp.lang.c In-Reply-To: <609@PT.CS.CMU.EDU> References: <4668@pyr.gatech.EDU> <495@xyzzy.UUCP> <9930@mimsy.UUCP> <10027@ut-sally.UUCP> Organization: NASA Langley Research Center, Hampton, VA Cc: Status: R In article <609@PT.CS.CMU.EDU> you write: >> Sorry, but in my opinion the similiarity between "==" and "=" is a >>flaw in the language. My attitude towards programming enviroments (languages >>comprise part that) is that one aspect the enviroment should provide is >>assisting programmers in developing software by insolating them against >>common errors they make. >As you say, these are your opinions. They are not facts, nor general >guidelines that I feel compelled to follow. Languages that do a lot >to `insolate' the programmers exist. Try Pascal. C does not do this, >nor, in my opinion and in that of many other programmers, should it. >> Claiming that its the programmer at fault won't, >But the programmer IS at fault. The machine does what you tell it to do, >not what you want it to do. If you can't write a simple routine to >check for = inside if statements, I'll be happy to write it for you. >Then you can check your programs and those of us who don't want to >be warned constantly about perfectly legitimate constructs won't have >to be. You are misreading my article. I do not propose changing the C language nor do I say the compiler should flag this contruct (it is perfectly valid construct for the language which I use myself). The language D should redefine assignment to := then hopefully this type of bug will go away. (ie. we should learn from our mistakes) >> (as in a Venus probe >>that had a bug in the software to the degree: for i=1.100 in Fortran ). >Do you have a reference for this? Or is it as unfounded as the rest of >your posting? O.K. here it is: From "Principles of Programming Languages: Design, Evaluation, and Implementation", Bruce J. MacLennan. pg 90-91 DO 20 I = 1. 100 which looks remarkably like the DO-statement: DO 20 I = 1, 100 In fact, it is an assignment statement to variable called "DO20I", which we can see by rearranging the blanks: DO20I = 1.100 You will probably say that no programmer would ever call a variable "DO20I", and that is correct. But suppose the programmmer intended to type the DO-statemnt above but accidently typed a period instead of a comma (they are next to each other on the keyboard). The statement will have been transformed into an assignment to "DO20I." The programmer will probably not notice the error because "," and "." look so much alike. In fact, there will be no clue that an error has been made because, conveniently, the variable DO20I will be automatically declared. If you think that thing like this can't happen, you will be surprised to learn that an American Viking Venus probe was lost because of precisely this error. BTW those people that claim they don't run into these types of bugs. What do you do all day write your 4 lines of code and that's it? Of course you make sure those lines are bug free. Try producing 400+ line a day. Geez -- Eddie Wyatt e-mail: edw@ius1.cs.cmu.edu