Double break

  • Thread starter those who know me have no need of my name
  • Start date
M

Mark McIntyre

So what's your point?

My experience is that goto is such a blunt instrument that once you start
using it, you rapidly destroy the program flow and logic. Beginners in
particular should /never/ use it - its far too easy to spaghettise a
programme. Put it in the scanf() category of C features.
An explicit break construct would be slightly
nicer for readability, but it needs to identify which loop it's
breaking from, so it needs some kind of label.

Serious remark: you just need to redesign the algo a little. I have
/never/ in, oh, nearly 20 years of programming, found a case where I could
not write code which avoided a goto and at the end was more elegant and
better structured.
 
A

Alan Balmer

I disagree that the former method has anything to do with the control
structure, but I won't argue the point.

I don't really see any room for disagreement, unless you interpret the
statement much differently than I intended it. Leaving the "for"
control structure is precisely what the "break" does. The goto has no
such relation to the "for" structure. Perhaps I phrased it badly.
I will simply ask if you would use
this same method for an Nth dimensional loop, where N is any positive
integer. Sure, nested loops 3 or more deep are rare (and probably in most
cases bad), but would you really argue the "if (flag) break;" mechanism is
better to break out of several levels of scope, simply to avoid a single
goto?
Not necessarily. I would look at the particular situation. Most likely
I would find that there was a better way to do it ;-)
 
X

Xenos

Alan Balmer said:
On Tue, 15 Jun 2004 12:53:43 -0400, "Xenos"
I don't really see any room for disagreement, unless you interpret the
statement much differently than I intended it. Leaving the "for"
control structure is precisely what the "break" does. The goto has no
such relation to the "for" structure. Perhaps I phrased it badly.
I didn't mean the break statements. I meant the flag and the if statement
to trigger the break. But again, I won't argue the point.

Regards,

DrX
 
G

Guest

those said:
in comp.lang.c i read:


then why post it?

Because, not being the universe a running program
in an Operating System, I like, sometime, not always respect rules (*).

- Dario

(*) Sorry for my horrible english, but be assured:
my C (and Java) sentences are better than my english sentences.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top