Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: while loop condition doesn't work Date: Mon, 30 Jan 2017 14:09:51 -0800 Organization: None to speak of Lines: 47 Message-ID: References: <750784a4-22dc-44ef-8972-34d4fb048b00@googlegroups.com> <871svxdiu9.fsf@bsb.me.uk> <87pojhbw2h.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="a9fae22b5f567322e337da4e19df7ab9"; logging-data="25319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hGZK9ptdbQkjLYWbBOZr3" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:5Ru+MNRxU8FVveSe4JTQOfAVE7E= sha1:ayJn+FaxB1eJWyspLGu4msV9svM= Xref: csiph.com comp.lang.c:102808 Tim Rentsch writes: [...] > This brings up what I think is a more interesting point. In > writing programs for students, it's fairly common to use comments > not because the author thinks the program needs it, but because > it is throught the students need it. Unfortunately this habit > frequently leads to students thinking that sort of commenting > style is how programs should normally be written. That's bad and > even worse self-perpetuating. To fix it we should stop writing > such "educational" comments in any example code, including > (especially) code written with an educational purpose in mind. > > Please consider putting any educational commentary outside the > actual code, rather that giving it as comments inside the code. I agree that there's a problem. I'm not sure eliminating such comments or moving them elsewhere is the best solution. For a student just beginning to learn the language, comments like these: int i; /* Create an object named "i" of type int */ i = 42; /* Assign the value 42 to i */ i ++; /* Increment i by 1 */ as annoying as they might be, can actually be useful. For example the meaning of "++" is not obvious to a non-programmer, and having a reminder close to where it's used can be a good reminder. Putting them outside the code is going to make it more difficult for the reader to associate the comments with the relevant code. Perhaps one could use some special marker, with a comment at the top (and an explanation by the instructor) saying that any marked comments are intended to explain the language features and should not be included in real code. int i; /* TUT: Create an object named "i" of type int */ i = 42; /* TUT: Assign the value 42 to i */ i ++; /* TUT: Increment i by 1 */ (It's been a long time since I was a beginning programmer, so it's hard for me to tell what would work best.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"