Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #102808

Re: while loop condition doesn't work

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
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 <ln37g09p3k.fsf@kst-u.example.com> (permalink)
References <750784a4-22dc-44ef-8972-34d4fb048b00@googlegroups.com> <871svxdiu9.fsf@bsb.me.uk> <e9b02777-9542-4e5b-bbf7-885c9bbcb5da@googlegroups.com> <87pojhbw2h.fsf@bsb.me.uk> <d4616907-128c-442d-b29e-82bf47b4e83d@googlegroups.com> <o5tcfb$ap3$1@dont-email.me> <o5tf8a$lpn$1@dont-email.me> <o5tfrf$o7q$1@dont-email.me> <kfnbmuoff0p.fsf@x-alumni2.alumni.caltech.edu>
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

Show key headers only | View raw


Tim Rentsch <txr@alumni.caltech.edu> 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  <http://www.ghoti.net/~kst>
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"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 01:24 -0800
  Re: while loop condition doesn't work mark.bluemel@gmail.com - 2017-01-20 03:29 -0800
  Re: while loop condition doesn't work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-20 12:19 +0000
    Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 05:12 -0800
      Re: while loop condition doesn't work Richard Heathfield <rjh@cpax.org.uk> - 2017-01-20 13:17 +0000
        Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 05:20 -0800
        Re: while loop condition doesn't work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-20 15:07 +0000
    Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 05:31 -0800
      Re: while loop condition doesn't work Manfred <noname@invalid.add> - 2017-01-20 15:23 +0100
      Re: while loop condition doesn't work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-20 15:16 +0000
        Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 07:45 -0800
          Re: while loop condition doesn't work Richard Heathfield <rjh@cpax.org.uk> - 2017-01-20 16:06 +0000
            Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 08:37 -0800
            Re: while loop condition doesn't work David Brown <david.brown@hesbynett.no> - 2017-01-20 17:54 +0100
              Re: while loop condition doesn't work Richard Heathfield <rjh@cpax.org.uk> - 2017-01-20 17:04 +0000
                Re: while loop condition doesn't work David Brown <david.brown@hesbynett.no> - 2017-01-20 19:08 +0100
                Re: while loop condition doesn't work Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 12:51 -0800
                Re: while loop condition doesn't work Keith Thompson <kst-u@mib.org> - 2017-01-30 14:09 -0800
                Re: while loop condition doesn't work supercat@casperkitty.com - 2017-01-30 14:57 -0800
                Re: while loop condition doesn't work Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-01 21:31 -0800
                Re: while loop condition doesn't work Keith Thompson <kst-u@mib.org> - 2017-02-02 10:01 -0800
                Re: while loop condition doesn't work Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 00:22 -0800
              Re: while loop condition doesn't work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-20 19:12 +0000
                Re: while loop condition doesn't work Richard Heathfield <rjh@cpax.org.uk> - 2017-01-23 10:54 +0000
            Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 23:22 -0800
              Re: while loop condition doesn't work Richard Heathfield <rjh@cpax.org.uk> - 2017-01-23 11:02 +0000
            Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-21 01:22 -0800
              Re: while loop condition doesn't work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-21 11:00 +0000
                Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-21 08:35 -0800
                Re: while loop condition doesn't work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-21 17:17 +0000
                Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-21 09:32 -0800
          Re: while loop condition doesn't work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-20 19:16 +0000
            Re: while loop condition doesn't work Richard Heathfield <rjh@cpax.org.uk> - 2017-01-23 11:03 +0000
    Re: while loop condition doesn't work David Brown <david.brown@hesbynett.no> - 2017-01-20 14:34 +0100
      Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 07:40 -0800
        Re: while loop condition doesn't work Richard Heathfield <rjh@cpax.org.uk> - 2017-01-20 15:47 +0000
          Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 08:26 -0800
            Re: while loop condition doesn't work David Brown <david.brown@hesbynett.no> - 2017-01-20 18:01 +0100
              Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 09:26 -0800
                Re: while loop condition doesn't work David Brown <david.brown@hesbynett.no> - 2017-01-20 19:02 +0100
                Re: while loop condition doesn't work Alla _ <modelling.data@gmail.com> - 2017-01-20 10:13 -0800
                Re: while loop condition doesn't work Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-21 05:36 -0800

csiph-web