[comp.lang.c] meaning of continue

rob@raksha.eng.ohio-state.edu (Rob Carriere) (10/29/90)

In article <ie2RR1w161w@phoenix.com> stanley@phoenix.com (John Stanley) writes:
>dik@cwi.nl (Dik T. Winter) writes:
>
>> Calm down please.  Rahul Dhesis idea is not that wrong.
>
>   I am perfectly calm. The definition of continue was both fatally
>anthropomorphic and incorrect.

The fatality of course only applies to those of us who are allergic to
anthropomorphisms.  The rest of us is fortunately able to use a very powerful
mental tool. 

>>  >             The correct definition of "continue", in the C language
>>  > context, is "go to the top of the smallest enclosing while, do, or for."
>> This is wrong, it is not go to the top, but go to the bottom!
>
>   Please argue with M.I. Bolsky of the Systems Training Center at AT&T
>Bell Labs. This is a direct quote of his. 

So?  I would accept K&R or H&S quotes (for pre-ANSI C), or quotes from the
standard (for ANSI C).  Anything else is what the courts call hearsay.

If you want to exchange quotes, here's H&S2 (pg 217-218)
"Execution of a _continue_ statement causes execution of the body of the
smallest enclosing _while_, _do_ or _for_ statement to be terminated.  Program
control is immediately transferred to the end of the body..."
                                          ^^^^^^^^^^^^^^^
Aka the bottom...

>   Your definition is also wrong. K&R 2ed, p. 65, "continue ... causes
>the the next iteration of the enclosing for, while, or do loop to begin."
>It does not refer to "Hey, you! Try again", nor to "go to the bottom".

Please observe that K&R2 contradicts your previous authority...  Also please
observe that the `definition' Mr. Winter supplied, while informal, will get a
human code-executer to do the right thing.  Finally, one could define continue
to mean that `execution continues with the test expression of the innermost
enclosing loop'.  Would you claim this wrong because K&R2 does not refer to
`test expression'?  In other words, your concept of correctness is flawed.

>> To correct Rahuls words:
>> 	"Hey you!  I have seen this, now please get the next one, if any!"
>
>   Still fatally anthropomorphic. And impolite. There is no "Thank you"
>statement. 

One is reminded of the subgroup of the social scientists who desperately try
to cast their every observation in the most polysyllabic terms available,
thinking to make their field appear more `scientific' that way.

Of all the engineering disciplines and all the `hard' sciences, Computer
Science is the only field where a significant fraction of the population
objects to anthropomorphisms.

SR
---

stanley@phoenix.com (John Stanley) (10/30/90)

rob@raksha.eng.ohio-state.edu (Rob Carriere) writes:
> 
> The fatality of course only applies to those of us who are allergic to
> anthropomorphisms.  The rest of us is fortunately able to use a very powerful
> mental tool. 

   No, the fatality applies to anyone who uses the powerful mental tool to
create extremely verbose, INCORRECT, confusing versions of computer
instructions. 

> So?  I would accept K&R or H&S quotes (for pre-ANSI C), or quotes from the 
> standard (for ANSI C).  Anything else is what the courts call hearsay.

   Who is H&S? They wrote C? I thought it was K&R. Anything but K&R or the
standard is hearsay. 

> >   Your definition is also wrong. K&R 2ed, p. 65, "continue ... causes
> >the the next iteration of the enclosing for, while, or do loop to begin."
> >It does not refer to "Hey, you! Try again", nor to "go to the bottom".
> 
> Please observe that K&R2 contradicts your previous authority...  Also please
> observe that the `definition' Mr. Winter supplied, while informal, will get a
> human code-executer to do the right thing.  

   Hmmm. Sorry. I thought the purpose of coding was to get a MACHINE to
do the right thing. I can misread code all day and do the right thing,
but if the computer doesn't it was all for naught.

   But you are right. K&R and Bolsky use different words. If I had had K&R
at my desk I would have quoted them first. If I still had a copy of the
standard, I would quote it. I still don't find anybody who defines
"continue" as "try to do it right this time". And note that Mr. Winter's
definition fails for "do ... while()" as the bottom of the loop is after
the condition test.  (Oho, you say. The loop ends BEFORE the while. If so,
the while would not be tested in the loop, and the loop would not exit.
Something that occurs on each pass through a loop is part of the loop.)

> Finally, one could define continu
> to mean that `execution continues with the test expression of the innermost
> enclosing loop'.  Would you claim this wrong because K&R2 does not refer to
> `test expression'?  In other words, your concept of correctness is flawed.

   One could define continue to mean "stop here. Pick up dirty clothing
from floor. Do laundry." If we are speaking C we should all use the same
definitions. 

   What happens in the case "for(i=0;;i++) {...}". There is NO test
expression. How do you continue with a test expression that doesn't exist?
(Oho, you say. Just skip it if it isn't there. Your definition doesn't say
that. K&R's didn't need to add words for special cases.) Or, better:

	for( i=0; ; i++ ) {
		/* some code to do something */
		if( 10 < i ) break;
		/* more code to do something else */
		if( 20 < j ) continue;
		/* even more code */
	}

Here the test expression is IN THE MIDDLE of the loop. Your definition:
jump to the test expression. Skip /* some code */. K&R: begin next
iteration, which includes the i++ and /* some code */.

   Remember, the definitions we put on computer language elements must be
clear yet flexible. If I wrote compilers, I would see the mandate that
continue jump to the condition test as a mandate for condition test. No
condition test, syntax error. Notice how long it took for X3J11 to create
a standard, and there are STILL questions and unclear areas.
> 
> Of all the engineering disciplines and all the `hard' sciences, Computer 
> Science is the only field where a significant fraction of the population 
> objects to anthropomorphisms.

   No. Chemistry, for one, does not try to force thought capability onto
molecules and atoms. Electronics does not. Nobody has EVER said to me
"the electrons in this AND gate see unfriendly electrons coming in both
entrances, so they run out the exit to get away." How do we explain the
NAND gate? Are the invaders suddenly friendly so the electrons that were
previously running away stay to have a party? If you were an electrical
engineer and you told your fellow engineers that was how you define the
AND gate, you better find a new job because you will never live it down.

   I have never had an electronics person tell me that it took time for
my soldering iron to get hot because "the iron is thinking about getting
hot." I have heard MANY supposedly computer literate people tell me that
it takes a while to process that data because "there is a lot of data for
the computer to think about." Why does it take so long for a chess
playing computer to make a move, sometimes? "Why, there are a lot of
moves to think about."

   In fact, most 'hard' sciences tend to deal with numbers. Numbers make
it very hard to anthropomorphize. Maybe if more computer 'scientists'
would STOP anthropomorphizing, the science would become one instead of
the art it is now.

   The original definition mentioned in this thread was wrong. It applied
too much human instinct (I am tired of typing anthropomorphism. Drat,
typed it again, anyway) to a simple machine command. It led to incorrect
understanding of what the command was supposed to do. That is the real
danger of anthro... -- misunderstanding of what is really happening. It
makes people think that machines think, too. That it really IS the
machine's fault when the computer printed check is wrong. When the phone
switching network malfunctions under a load of CCIS signalling messages.
When the Airbus 320 fly-by-wire directs the plane into the ground.

   Computers don't make mistakes. People who program them do. People who
program them incorrectly want you to think computers made the mistakes, so
they tell you that computers think. That they refer to each other as "Hey!
You!" That they "try to do it right". That it is nobody's fault when your
credit card bill is $1,000,000.  Who made the mistake? THE COMPUTER!

"Arinth is a beautiful planet." "Oh, have you been there?"
  "Yes, but not yet." The Doctor. (TB)

chris@mimsy.umd.edu (Chris Torek) (10/30/90)

In article <6ecTR1w161w@phoenix.com> stanley@phoenix.com (John Stanley)
writes a rather vitriolic message, including the following:
>Who is H&S?

H is Samuel Harbison, and S is Guy L. Steele Jr.  Both of them are quite
intelligent fellows.

>They wrote C?

They worked together (at Tartan Labs) on a real C compiler, and in the
process discovered that there was no such thing as `the real C language'
---that there were a number of different, and sometimes incompatible,
dialects.  So they set out to document exactly what could and could not
be relied upon.

If you are working with a C system that predates ANSI X3.159-1989, the
book that resulted is the best reference you can buy.  (Note that K&R
1st ed. is not intended as a reference work.  Neither is K&R 2, for
that matter, but it is for ANSI C, not pre-ANSI C.)

Also:
>I thought the purpose of coding was to get a MACHINE to do the right thing.

Actually, no.  This is only a part of the task, though usually a large
part.  It is also important to make the result understandable: to the
people and/or machines that will use it; to the people and/or software
that will maintain it; and so on.

As to the main point of the message (which I will not quote further), I
will say only this:  Anthropomorphism is a form of analogy, and analogy
is a very powerful tool for analysis, but also a dangerous one.  It is
right to be wary of analogies, but it is not right to reject them out
of hand simply because they *are* analogies.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris

scs@adam.mit.edu (Steve Summit) (10/30/90)

In article <6ecTR1w161w@phoenix.com> stanley@phoenix.com (John Stanley)
climbs up even higher onto his soapbox and rails against
misleading anthropomorphization, computer illiteracy, and the
general decline of Western society.  (In fact, I don't disagree
with anything he said, but feel that, in the current context, it
is quite misdirected.)

May I remind the participants in this increasingly vitriolic and
picky debate that it was spawned by Rahul Dhesi's musings on the
stylistic appropriateness of a particular empty loop body?  I
very seriously doubt that Rahul, or anybody else here, has any
misunderstandings about what

	while(*p++ != '\0')
		continue;

does (i.e. means to the compiler).  At issue was merely what it
might mean to the casual, human reader, and whether

        while(*p++ != '\0')       or       while(*p++ != '\0')
                ;                                  {}

might be clearer.  (Not "more correct," just clearer.)  As we
should all know by now, these discussions on program layout
(which frequently masquerade under the subject "style," which is
unfortunate, because programming style is far more important than
mere layout) frequently turn into religious battles.  Shall we
discuss brace placement for a while :-) ?  (Footnote for the
terminally clueless: the :-) means that I am being sarcastic here
and shall be very upset if someone responds to this suggestion.)

                                            Steve Summit
                                            scs@adam.mit.edu

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (10/30/90)

In article <27261@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes:
> If you are working with a C system that predates ANSI X3.159-1989, the
> book that resulted is the best reference you can buy.  (Note that K&R
> 1st ed. is not intended as a reference work.  Neither is K&R 2, for
> that matter, but it is for ANSI C, not pre-ANSI C.)

I have to disagree with this. K&R (the real one) can be used as a
reference. If you recognize its ambiguities as true ambiguities, you'll
write much more portable code.

I don't think I've ever used an enum. Why not? Because they aren't in
the language I think of as C. The result? My code is more portable.
Would this be true if I used H&S as a reference? I doubt it.

---Dan

stanley@phoenix.com (John Stanley) (10/31/90)

chris@mimsy.umd.edu (Chris Torek) writes:

> In article <6ecTR1w161w@phoenix.com> stanley@phoenix.com (John Stanley)
> writes a rather vitriolic message, including the following:
                  ^IYHO, but not mine, nor intended
> >Who is H&S?
> >They wrote C?
   The question came up because they were quoted as authorities. Since they
didn't design the language, or issue the ANSI standard, they are second
hand info, and hearsay. I was told MY reference was invalid for that
reason, then immediatley had them quoted to me.

> >I thought the purpose of coding was to get a MACHINE to do the right thing.
> 
> Actually, no.  This is only a part of the task, though usually a large
> part.  It is also important to make the result understandable: to the
> people and/or machines that will use it; to the people and/or software
> that will maintain it; and so on.

   However, having code that humans think does one thing and the machine
'thinks' should do another is worth less than 0. It does not do what it
should, and probably does nothing worthwhile, and it will require
resources to fix.  Code that executes properly but is unmaintainable is
worth something. Otherwise, why would executable-only software cost so
much? 
> 
> As to the main point of the message (which I will not quote further), I 
> will say only this:  Anthropomorphism is a form of analogy, and analogy 
> is a very powerful tool for analysis, but also a dangerous one.  It is 
> right to be wary of analogies, but it is not right to reject them out 
> of hand simply because they *are* analogies.

   The analogy was rejected because it was flawed, not 'out of hand'. It
was causing the original poster confusion, and was thus falling into
'dangerous' mode. It was a VERY extreme case of analogy, and would be
dangerous even were it correct. Any non-computer literate person who
hears such definitions of language elements will certainly draw improper
conclusions about computers, and there is already too much of that. New
programmers will hear others use it and think it is the correct way to
think about the language. 





"Arinth is a beautiful planet." "Oh, have you been there?"
  "Yes, but not yet." The Doctor. (TB)

staff@cadlab.sublink.ORG (Alex Martelli) (11/02/90)

rob@raksha.eng.ohio-state.edu (Rob Carriere) writes:
	...
>human code-executer to do the right thing.  Finally, one could define continue
>to mean that `execution continues with the test expression of the innermost
>enclosing loop'.  Would you claim this wrong because K&R2 does not refer to
>`test expression'?  In other words, your concept of correctness is flawed.

I *WOULD* indeed claim that saying that continue means "proceed with
the test expression of the innermost enclosing loop" is wrong - if
said loop is for(<a>;<b>;<c>), executions on a continue proceeds with
the *increment* expression <c>, NOT with the test expression <b>!
-- 
Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 45, Bologna, Italia
Email: (work:) staff@cadlab.sublink.org, (home:) alex@am.sublink.org
Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; 
Fax: ++39 (51) 366964 (work only), Fidonet: 332/401.3 (home only).

gwyn@smoke.brl.mil (Doug Gwyn) (11/07/90)

In article <6065@raksha.eng.ohio-state.edu> rob@raksha.eng.ohio-state.edu (Rob Carriere) writes:
-Of all the engineering disciplines and all the `hard' sciences, Computer
-Science is the only field where a significant fraction of the population
-objects to anthropomorphisms.

So, how DOES the electron decide which slit to go through??

kdq@demott.COM (Kevin D. Quitt) (11/07/90)

In article <14370@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes:
>In article <6065@raksha.eng.ohio-state.edu> rob@raksha.eng.ohio-state.edu (Rob Carriere) writes:
>-Of all the engineering disciplines and all the `hard' sciences, Computer
>-Science is the only field where a significant fraction of the population
>-objects to anthropomorphisms.
>
>So, how DOES the electron decide which slit to go through??


    Depends whether anyone's watching.  Is it true that Computer Science
is to Science as Plumbing is to Hydrodynamics?

-- 
 _
Kevin D. Quitt         demott!kdq   kdq@demott.com
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  MODEM (818) 997-4496 PEP last

                96.37% of all statistics are made up.

rob@kaa.eng.ohio-state.edu (Rob Carriere) (11/09/90)

In article <14370@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes:
>In article <6065@raksha.eng.ohio-state.edu> rob@raksha.eng.ohio-state.edu (Rob Carriere) writes:
>-Of all the engineering disciplines and all the `hard' sciences, Computer
>-Science is the only field where a significant fraction of the population
>-objects to anthropomorphisms.
>
>So, how DOES the electron decide which slit to go through??


It flips an Italian Lire...
SR
---