interval switch

i want to make switch contain value for example
if was 12.56>x>4.68 goto function mystring
& switch code not suitable for float
& not suitable using " for " also
Well, very simple, then.
1
2
3
4
if (x>4.68 && x<12.56)
	mystring();
else
	//... 
using goto control make many problem
can u explan it more than in the articles
& thanx for the frist
It's not that using goto causes problems. It's abusing it that does. It tend to create what is known as spaghetti code, which is hard to read and debug.
However, and despite what many programmers may say, not using it when it would clearly give an advantage is not a good thing, either. Currently, the only place where using goto is not frowned upon is when breaking from inside nested loops, and even then care should be taken. If used correctly, goto can actually simplify code and increase its readability. If used incorrectly, however...
So, goto is considered harmful, but without merit.

(IMO, as usual.)
You didn't read Dijkstras artikle, did you? He stated:
"Since a number of years I am familiar with the observation that the quality of programmers is a decreasing function of the density of go to statements in the programs they produce"
So your "without merit" statement really is a persomal opinion, and although you stated that, it is somewhat strange to read it in the exact wording this article has coined.
See http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF
Last edited on
Sigh. More rabid fanatacism.
http://www.cplusplus.com/forum/beginner/2287/page1.html#msg8648

... please please re-read both articles. You'll learn that (1) Dijkstra didn't hate GOTO, and (2) Knuth didn't disagree with Dijkstra.
--by Duoas

I find it amazing how often these two articles are quoted to support assertations at odds with their content. That amazement is actually the point of Knuth's article about Dijkstra's.

The problem with attacking the tool instead of the tooler is that the underlying problem is blissfully forgotten and remains undiagnosed by multitudes of programmers in their programming practices.
--by myself again

So, what is meant by "goto is evil"?
http://www.parashift.com/c++-faq-lite/big-picture.html#faq-6.15

Don't hate goto. Hate fanatacism (aka Bad Programming).
You didn't read Dijkstras artikle, did you?
I didn't bother. And I wasn't referring to what Dijkstra said. I was quoting the title of his article to refer to the impression many programmers have of goto.

I agree with Duoas. Don't blame the hammer hammering the screw. Blame the idiot trying to nail a screw.
I'll post a thing similar to what I said in Duoas's link to a thread on the beginner forum above...

How did we get from helping someone to a radical debate?

*Expects Grey Wolf to give the response he did in that one thread*

Ok. Now to put in my 2 cents.

Goto is not the problem, and can be perfectly valid, unless used like this:

1
2
3
4
5
6
7
8
9
top:
goto bottom;
middle:
goto somewhere_else;
bottom:
goto middle;
/* code..... */
somewhere_else:
goto top;

Reasonable use of goto is perfectly OK. "Spaghetti-ing" is NOT good practice.

So NYEH.
Last edited on
Topic archived. No new replies allowed.