Path: utzoo!attcan!uunet!aplcen!samsung!rex!wuarchive!mit-eddie!uw-beaver!ubc-cs!alberta!mts.ucs.UAlberta.CA!Al_Dunbar From: userAKDU@mts.ucs.UAlberta.CA (Al Dunbar) Newsgroups: comp.lang.c Subject: Re: Assignment in test: OK? Message-ID: <1327@mts.ucs.UAlberta.CA> Date: 13 Sep 90 01:08:06 GMT References: <1990Sep5.185451.25532@DRD.Com> Organization: MTS Univ of Alberta Lines: 42 In article , burley@world.std.com (James C Burley) writes: >In article <18326@ultima.socs.uts.edu.au> jeremy@sinope.socs.uts.edu.au (Jeremy Fitzhardinge) writes: > > >> BTW, if I ever write a new C-like language, ":=" will be the assignment > >> operator, "==" the comparison operator, and "=" totally invalid! Although > > If you are going to prevent assignment in a conditional, you are preventing > > >I doubt anyone could seriously disagree with an argument that it would have >saved much unnecessary debugging effort if, from the beginning, K&R had >realized that making "=" an assignment OPERATOR (thus allowing it to work as >an operator inside an expression) was a mistake -- it meant they had to make >"==" the comparison operator, which no other language I know of ever had to, >because others do not allow assignment as an operator. Given that most people >would at one point or another accidentally use "=" instead of "==", it would >have been great (20-20 hindsight) if they'd realized this from the beginning >and made ":=" or some such thing the assignment operator, leaving "=" out of >the picture. ..... Originally being a Fortran person, the ":=" assignment operator always seemed to me an abomination, both in terms of style and inconvenience. Now that I spend more time with C, the =/== problem (to say nothing of &/&& etc) hasn't bothered me as much as I once thought it would. This isn't to say that I haven't made the dreaded mistake, of course. But that's not my point. My point is that I don't recall anyone confusing the assignment and comparison operators in (at least pre-90) Fortran: A .EQ. B + C IF(A = D) GOTO 999 The reason is twofold: a) the compiler doesn't allow either substitution, and b) '=' and '.EQ.' do not look at all alike. It is just too bad that there are not enough special punctuation marks to allow unambiguous use of single character operators for such things as ==, <=, &&, etc. -------------------+------------------------------------------- Al Dunbar | Edmonton, Alberta | this space for rent CANADA | -------------------+-------------------------------------------