Path: utzoo!attcan!uunet!lll-winken!brutus.cs.uiuc.edu!usc!ucsd!ucsdhub!hp-sdd!hplabs!hpl-opus!hpccc!hpcc01!hp-ses!hpcuhb!hpda!hpcupt1!jamiller From: jamiller@hpcupt1.HP.COM (Jim Miller) Newsgroups: comp.lang.c Subject: Re: problems/risks due to programming language, stories requested Message-ID: <5940020@hpcupt1.HP.COM> Date: 14 Mar 90 18:52:22 GMT References: <9790@medusa.cs.purdue.edu> Organization: Hewlett Packard, Cupertino Lines: 60 >> >>See how I left out the breaks on purpose. > >Cross you heart, how often in practical programming do you >write such code? And how often compared to normal switch >statements where an easily elided break would introduce >a simple bug? It might be that I never program in C, but I >have never felt the need for a fall-through. Also, it seem more I have often written such code, in several different languages. I implement some sort of "continue" statement. case (i) of begin 1: ... 2: ... goto continue2; 3: continue2: ... 4: ... ... Now I don't frequently do this, and as compared to the normal "break" case it is very small. However it IS a useful construct. Here is my $.02 on the subject of: a few of my favorite C "flaws". 1) The here-to-for & often mentioned break in the switch statement. A language that has "x++" so that a programmer will not make a mistake writing "x=x+1" is inconsistent is having a situation where he/she/it must have a separate statement for the normal coding practice. IF I were to get into my time machine, I'd try to get C changed to implement a switch "continue" construct instead of the switch's "break". Right now I think it better be left alone, any fix that I can see would intail an imposible and or ugly transition. 2) "==" for logical equal compare. I don't like it because *I* make the mistake of "=" instead of "==" often in "if" conditions. Also I find it difficult to find such mistakes because I also intentionally use "=" in "if" conditions. (One personal solution is to stop using "=" in conditions.) I don't know what I'd replace it by because I haven't found any alternative that I like -- and I've seen quite a few. The closest to my personal liking is using ":=" instead of "=" for assignment. All those opposed to typing two characters instead of one should agree with my above "continue" position -- but I bet they won't. "==" v.s. "=" is *my* greatest single typing error (as opposed to logical or coding error) that I make which does not get caught by the compiler and/or lint. Yes I know that | v.s. || and & v.s. && have the same "problem". It's just that I personally don't have the same problem. I think it is because "|" and "&" don't get used with the frequency of "=". I double check my use of both the single and the double usages whenever there is a hint of a problem. I also tend to double check them when I first type them. But double checking each "=" is not in me. jim - it's only my opinion so of course it's TRUTH - miller