473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

why are GOTO's not used ...

why are GOTO's not used they just a simple JMP instructions what's bad
about them
Aug 17 '08
59 4966
santosh wrote:
Herbert Rosenau wrote:
>On Mon, 18 Aug 2008 22:20:32 UTC, "Bartc" <bc@freeuk.comwrote:

>>That's a far-fetched example. Used properly, to augment existing
control structures, Goto is not such a big deal as people seem to
think. Used by code-generaters (generating C-code) it's a non-issue
because the code will never be seen or maintained.

And it's a natural control structure that many people will be
familiar with, eg. on lists of instructions and any number of forms
("If you answered No, please proceed to question 8...").

Of course it can be abused, but so can lots of things.

Why get I so easy confused? Whenever I see the letters Twink I read
them as Twit. Any idea why it is so?

No idea, but in any case, why are you asking *Bartc* this question,
instead of Twink?
Maybe because Twink didn't write a single article in this thread?

Bye, Jojo
Aug 21 '08 #51
Keith Thompson <ks***@mib.orgwrites:
Joe Wright <jo********@comcast.netwrites:
>Les Cargill wrote:
>>Herbert Rosenau wrote:
On Mon, 18 Aug 2008 22:20:32 UTC, "Bartc" <bc@freeuk.comwrote:
<snip>
goto IS abusitive always.

And all universal statements are false :)

It was Bertrand Russell I think..
"All generalities are false, including this one."

<OT>
"generalizations", not "generalities". A quick Google search turns up
a couple of attributions to Mark Twain, but I remember it being
attributed to Voltaire, or maybe it was Descartes.
</OT>
If I may <OTjust a little more. The attribution or mis-attribution
to Russell is natural since it is his name that has become attached
this whole class (mathematical pun intended) of paradoxes. My
favourite example in programming (I can't get it back to C) was a
SNOBOL pattern that matched only those patterns that did not match
themselves. The program, of course, matched this pattern to itself.

--
Ben.
Aug 21 '08 #52
"Herbert Rosenau" <os****@pc-rosenau.dewrites:
On Wed, 20 Aug 2008 21:00:55 UTC, ri*****@cogsci.ed.ac.uk (Richard
Tobin) wrote:
>In article <wm***************************@JUPITER.PC-ROSENAU.DE>,
Herbert Rosenau <os****@pc-rosenau.dewrote:
>No, got breaks the flow. It requires a label somewhere.

So it breaks the flow. So what? Are you suggesting that correctly
written programs have unbroken flow?
>The existence
of a label is a sign to seharch for multiple gotos somewhere else. and
breaks the flow only because it exists.

Most functions I've written that use goto have only one label.

wheras a label has always an unknown number of source. So goto makes a
program unmaintable always!

It doesn't matter if a function has currently ony one ore one million
gotos. Having a lable makes the whole program unmaintable because at
the point the label exist there is absolutely nothing that says that
this label is reached fom only one point and where that point is and
what state the flow has. There is in no way a need for goto. There is
noways a need to set a lablel as destination of a goto. When you means
you needs a goto then your design is highly buggy and needs to be
replaced by another one.
[...]

As many people have said, "All generalizations are false, including
this one".

I don't remember the last time I used a goto (other than in some
scripting "language" that really didn't have anything better); I'm not
sure that I've *ever* written a goto in C.

Having said that, a goto statement and its target label are always
within the same function. If that function is short enough, a moment
of reading is enough to ensure that there's only one goto statement
and only one label.

For example:

int foo(blah)
{
for (blah; blah; blah) {
for (blah; blah; blah) {
if (need_to_bail_out_now) {
goto ERROR;
}
}
}
return OK;

ERROR:
return ERROR_FLAG;
}

Given sufficiently clear identifiers, the control flow is fairly
obvious and maintenance shouldn't be too much of a problem. Here the
goto statement substitutes for C's lack of a multi-level break.

Now a lot of programmers would restructure this code to avoid the
goto. I would very likely do so myself. But that's largely a matter
of taste. The (pseudo-)code as written, even with a goto statement,
isn't "highly buggy".

Yes, every program that uses gotos can be rewritten to avoid them;
that's a theorem that's been known for decades. That *doesn't* imply
that the gotoless version is unambiguously better.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 21 '08 #53
On Aug 20, 3:09*pm, "Herbert Rosenau" <os2...@pc-rosenau.dewrote:
On Mon, 18 Aug 2008 22:20:32 UTC, "Bartc" <b...@freeuk.comwrote:
That's a far-fetched example. Used properly, to augment existing control
structures, Goto is not such a big deal as people seem to think. Used by
code-generaters (generating C-code) it's a non-issue because the code will
never be seen or maintained.

No, got breaks the flow. It requires a label somewhere. The existence
of a label is a sign to seharch for multiple gotos somewhere else. and
breaks the flow only because it exists.
And it's a natural control structure that many people will be familiar with,
eg. on lists of instructions and any number of forms ("If you answered No,
please proceed to question 8...").

No, it hinders to see the real flow. It is a real break in
maintenance. However wwhen you has to maintain a program that was
written some years ago by somebody who has left that job it's always
hard and timecostly to get tthe idea he had how to write that goto,
how the label was set .... it makes it really hard to maintain this
mixup of labels and gotos.
Of course it can be abused, but so can lots of things.

goto IS abusitive always.

--
Tschau/Bye
Herbert

Visithttp://www.ecomstation.dethe home of german eComStation
eComStation 1.2R Deutsch ist da!
I once had to fix a program by a coder who was new to C but evidently
thought he was the bee's knees.Had a few gotos which were easy but he
insisted on complicated return expression (return <expression>).
Debugging that just plain s*cked.
Aug 21 '08 #54
On 21 Aug 2008 at 16:19, Joachim Schmitz wrote:
santosh wrote:
>Herbert Rosenau wrote:
>>On Mon, 18 Aug 2008 22:20:32 UTC, "Bartc" <bc@freeuk.comwrote:
Of course it can be abused, but so can lots of things.

Why get I so easy confused? Whenever I see the letters Twink I read
them as Twit. Any idea why it is so?

No idea, but in any case, why are you asking *Bartc* this question,
instead of Twink?

Maybe because Twink didn't write a single article in this thread?
Huh? I'm confused...

Aug 21 '08 #55
Antoninus Twink wrote:
On 21 Aug 2008 at 16:19, Joachim Schmitz wrote:
>santosh wrote:
>>Herbert Rosenau wrote:
On Mon, 18 Aug 2008 22:20:32 UTC, "Bartc" <bc@freeuk.comwrote:
Of course it can be abused, but so can lots of things.

Why get I so easy confused? Whenever I see the letters Twink I read
them as Twit. Any idea why it is so?

No idea, but in any case, why are you asking *Bartc* this question,
instead of Twink?

Maybe because Twink didn't write a single article in this thread?

Huh? I'm confused...
I correct resp. extend my statement: ... before his (Herbert's) post.

Don't worry, this isn't supposed to make any sense, and was carefully
designed to confuse.
That's what GOTOs are all about after all 8-)

Bye, Jojo
Aug 21 '08 #56
Joachim Schmitz wrote:
santosh wrote:
Herbert Rosenau wrote:
....
Why get I so easy confused? Whenever I see the letters Twink I read
them as Twit. Any idea why it is so?
No idea, but in any case, why are you asking *Bartc* this question,
instead of Twink?

Maybe because Twink didn't write a single article in this thread?
That just moves the question farther back, without truly answering it.
Why was a comment about the letters "Twink" posted to a thread in
which those letters never occurred?
Aug 21 '08 #57
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote:
>Having said that, a goto statement and its target label are always
within the same function. If that function is short enough, a moment
of reading is enough to ensure that there's only one goto statement
and only one label.
What's more, unlike other control structures, the user chooses a
name for the target.

This:
goto ERROR;
makes the intention - that the transfer occurs when there's an error -
clear in a way that C's other within-function control structures
don't.

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Aug 21 '08 #58
On Thu, 21 Aug 2008 16:40:30 UTC, Keith Thompson <ks***@mib.org>
wrote:

Having said that, a goto statement and its target label are always
within the same function. If that function is short enough, a moment
of reading is enough to ensure that there's only one goto statement
and only one label.

For example:

int foo(blah)
{
for (blah; blah; blah) {
for (blah; blah; blah) {
if (need_to_bail_out_now) {
goto ERROR;
Boo! ssimply return ERROR_FAILED; would not break the flow, disturb
sequence and hinder to get something more bad. When that nested
blocks were a little bit more complex I would break down the whole
function in hiding implemenation details in a lower level function(s).
This would win a better overview in what is going on, leaving goto out
the door.
}
}
}
return OK;

ERROR:
return ERROR_FLAG;
}

Given sufficiently clear identifiers, the control flow is fairly
obvious and maintenance shouldn't be too much of a problem. Here the
goto statement substitutes for C's lack of a multi-level break.
When you had had the job to maintain code written by others who are
never available to ask for this or that then you would hate each and
any got you hast to handle.
Now a lot of programmers would restructure this code to avoid the
goto. I would very likely do so myself. But that's largely a matter
of taste. The (pseudo-)code as written, even with a goto statement,
isn't "highly buggy".
It is because you'll gets highly overloded when you have to maintain
this crap later on.
Yes, every program that uses gotos can be rewritten to avoid them;
that's a theorem that's been known for decades. That *doesn't* imply
that the gotoless version is unambiguously better.
It is better to avoid goto always. You may write goto when you hates
anybody else and tries to make theyr work impossibe, you tries to
bring the company the code release into ruin or you are a coder (real
programmers would never use goto) without ability to think.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!
Aug 22 '08 #59
rio

"Herbert Rosenau" <os****@pc-rosenau.deha scritto nel messaggio
news:wm***************************@JUPITER.PC-ROSENAU.DE...
On Thu, 21 Aug 2008 16:40:30 UTC, Keith Thompson <ks***@mib.org>
wrote:

>Having said that, a goto statement and its target label are always
within the same function. If that function is short enough, a moment
of reading is enough to ensure that there's only one goto statement
and only one label.

For example:

int foo(blah)
{
for (blah; blah; blah) {
for (blah; blah; blah) {
if (need_to_bail_out_now) {
goto ERROR;

Boo! ssimply return ERROR_FAILED; would not break the flow,
Is it possible that you have a meaning too restrict for the word flow?
it is like i see flow has many dimensions
and other say "no it has one dimension only"
disturb
sequence and hinder to get something more bad.
the same routine that has the same difficulty
the goto one + indentation here seems the more readable

if the limit of complexity (for to be understandable by me) for a c routine
that use while() if() etc is 10 in C
it is 100 in assembly that use goto

if i have to say the true this is only for my home made
language that use some insane number of gotos (at last for you)
but seems more robust and sure of the one i wrote in c
When that nested
blocks were a little bit more complex I would break down the whole
function in hiding implemenation details in a lower level function(s).
This would win a better overview in what is going on, leaving goto out
the door.
> }
}
}
return OK;

ERROR:
return ERROR_FLAG;
}

Given sufficiently clear identifiers, the control flow is fairly
obvious and maintenance shouldn't be too much of a problem. Here the
goto statement substitutes for C's lack of a multi-level break.

When you had had the job to maintain code written by others who are
never available to ask for this or that then you would hate each and
any got you hast to handle.
if something is more readable, if you have to ask something to someone
for a goto, you have to ask 100 times more for a while() or other
>Now a lot of programmers would restructure this code to avoid the
goto. I would very likely do so myself. But that's largely a matter
of taste. The (pseudo-)code as written, even with a goto statement,
isn't "highly buggy".

It is because you'll gets highly overloded when you have to maintain
this crap later on.
>Yes, every program that uses gotos can be rewritten to avoid them;
that's a theorem that's been known for decades. That *doesn't* imply
that the gotoless version is unambiguously better.

It is better to avoid goto always. You may write goto when you hates
anybody else and tries to make theyr work impossibe, you tries to
bring the company the code release into ruin or you are a coder (real
programmers would never use goto) without ability to think.
at last cpu and oses seems understand what i say.
programming is not live in a heaven,
it is more like live in the hell but building the heaven.
--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!


Aug 22 '08 #60

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Michael | last post by:
Hi, I know I know its notoriously bad! I don't want to use it. I was wondering, does it still exist? If it does, I really don't understand how!? like what happens if you just goto halfway through...
51
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this...
37
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you...
17
by: Mike Hofer | last post by:
While I'd toyed with C, C++, and Java over the last 20 years or so, my principal language has been BASIC, QBASIC, then Visual Basic, and finally Visual Basic .NET. But lately, I've been using C#...
77
by: M.B | last post by:
Guys, Need some of your opinion on an oft beaten track We have an option of using "goto" in C language, but most testbooks (even K&R) advice against use of it. My personal experience was that...
34
by: electrician | last post by:
Perl has it, Basic has it, Fortran has it. What is so difficult about creating a goto command for JavaScript. Just set up a label and say go to it.
3
by: electrician | last post by:
Yes, no GOTO. This is a major blunder on part of the creators of these tools. GOTO gives the programmer the absolute control over the program. Yes, no matter what, a GOTO sends the program to...
17
by: SoftEast | last post by:
Hi Buddies, I have read a lot of stuffs regarding not using GOTO statements to opt a good programming style http://david.tribble.com/text/goto.html]. Can anybody give a particular lines of code...
7
by: raashid bhatt | last post by:
why are GOTO's not used they just a simple JMP instructions what's bad about them
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.