473,378 Members | 1,549 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,378 software developers and data experts.

The use of goto in C

Hi all,

In another forum I am involved in a discussion regarding the use of goto.
The initializer for the discussion was wether the use of goto should be
discourage with respect to this article from Dijkstra:
http://www.acm.org/classics/oct95/

My opinion in general is that goto should be avoided for any cost, much
like the opinion expressed by Dijkstra. The only place where goto should
be considered is in kernels and compilers for performance reasons.

But what about embedded systems? Someone here making embedded systems
which uses or not uses goto? What is your reason for doing it or not?

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/p...rch=0xE3E80917

Jan 24 '06 #1
9 4414
Michael Rasmussen wrote:
Hi all,

In another forum I am involved in a discussion regarding the use of goto.
The initializer for the discussion was wether the use of goto should be
discourage with respect to this article from Dijkstra:
http://www.acm.org/classics/oct95/

My opinion in general is that goto should be avoided for any cost, much
like the opinion expressed by Dijkstra. The only place where goto should
be considered is in kernels and compilers for performance reasons.

But what about embedded systems? Someone here making embedded systems
which uses or not uses goto? What is your reason for doing it or not?


Quite recently, there was a discussion on this exact topic here:

http://groups.google.com/group/comp....7e1ee864889edb

Hope this helps you. I don't think there's much to be added to it.

Cheers

Vladimir

PS
Personally, I fall into
judicious-use-in-very-specific-circumstances-is-OK camp.

Jan 24 '06 #2
On Tue, 24 Jan 2006 13:06:36 +0100, Michael Rasmussen <mi*@miras.org>
wrote:
Hi all,

In another forum I am involved in a discussion regarding the use of goto.
The initializer for the discussion was wether the use of goto should be
discourage with respect to this article from Dijkstra:
http://www.acm.org/classics/oct95/

My opinion in general is that goto should be avoided for any cost, much
like the opinion expressed by Dijkstra. The only place where goto should
be considered is in kernels and compilers for performance reasons.

But what about embedded systems? Someone here making embedded systems
which uses or not uses goto? What is your reason for doing it or not?


I make embeddd systems. Last tiem I used a goto, I has 17 years and
used BASIC. Sooo long.

Best regards

Zara
Jan 24 '06 #3
On Tue, 24 Jan 2006 04:17:16 -0800, Vladimir S. Oka wrote:

Quite recently, there was a discussion on this exact topic here:

http://groups.google.com/group/comp....7e1ee864889edb

Hope this helps you. I don't think there's much to be added to it.

Thank you, I will study it carefully:-)

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/p...rch=0xE3E80917

Jan 24 '06 #4
Michael Rasmussen wrote:
Hi all,

In another forum I am involved in a discussion regarding the use of goto.
The initializer for the discussion was wether the use of goto should be
discourage with respect to this article from Dijkstra:
http://www.acm.org/classics/oct95/

My opinion in general is that goto should be avoided for any cost, much
like the opinion expressed by Dijkstra. The only place where goto should
be considered is in kernels and compilers for performance reasons.
But what about embedded systems? Someone here making embedded systems
which uses or not uses goto? What is your reason for doing it or not?


See prior comp.lang.c threads.

--
"If you want to go somewhere, goto is the best way to get there." -K.
Thompson
Jan 24 '06 #5
Michael Rasmussen wrote:
My opinion in general is that goto should be avoided for any cost, much
like the opinion expressed by Dijkstra. The only place where goto should
be considered is in kernels and compilers for performance reasons.


In /compilers/? For /performance reasons/? Performance of the /compiler/?

I don't think I've ever written a plain goto inside a compiler, and
any performance leaks have been attributable to other, major, causes.
And just in case you're being incredibly picky, I've written a compiler
in a language with no goto, no return, no break, and a continue (spelt
"again") that was just part of pretend recursion.

I might just about believe in gotos for performance in automatically
generated parsers/lexers. Not without evidence, though, and automatically
generated code can get away with a lot ick factor.

--
Chris "understanding is a three-edged sword" Dollin
Jan 24 '06 #6
On Tue, 24 Jan 2006 13:39:35 +0000, Chris Dollin wrote:

I might just about believe in gotos for performance in automatically
generated parsers/lexers. Not without evidence, though, and automatically
generated code can get away with a lot ick factor.

It was this I was refering to:-)
--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/p...rch=0xE3E80917

Jan 24 '06 #7
Michael Rasmussen wrote:
On Tue, 24 Jan 2006 13:39:35 +0000, Chris Dollin wrote:

I might just about believe in gotos for performance in automatically
generated parsers/lexers. Not without evidence, though, and automatically
generated code can get away with a lot ick factor.

It was this I was refering to:-)


The hand-written parsers and lexers I've done didn't seem to suffer
that much from performance problems. (And were I generating a
parser/lexer, I'd not pick gotos for /performance/ reasons [1] - I
might pick them for /expressivity/ if the compiler that compiled
them couldn't generate decent code otherwise - and in that case,
I'd prefer to spend the effort on that aspect of the compiler).

[1] Without empirical evidence.

--
Chris "understanding is a three-edged sword" Dollin
Jan 24 '06 #8
In article <pa***************************@miras.org>,
Michael Rasmussen <mi*@miras.org> wrote:
Hi all,

In another forum I am involved in a discussion regarding the use of goto.
The initializer for the discussion was wether the use of goto should be
discourage with respect to this article from Dijkstra:
http://www.acm.org/classics/oct95/
Oh no, not again.
My opinion in general is that goto should be avoided for any cost,
That opinion is stupid. I take a gun to your head. I give you the
choice: Write a loop using goto's, and you live. Write a loop using the
for () statement, and you die. The cost is your life. Do you still think
goto should be avoided at any cost?
much like the opinion expressed by Dijkstra.
You are missing quite a bit of historical context.
The only place where goto should
be considered is in kernels and compilers for performance reasons.


I've rarely heard such a stupid argument for using goto's.
Jan 24 '06 #9
On 2006-01-24, Christian Bau <ch***********@cbau.freeserve.co.uk> wrote:
In article <pa***************************@miras.org>,
Michael Rasmussen <mi*@miras.org> wrote:
Hi all,

In another forum I am involved in a discussion regarding the use of goto.
The initializer for the discussion was wether the use of goto should be
discourage with respect to this article from Dijkstra:
http://www.acm.org/classics/oct95/


Oh no, not again.
My opinion in general is that goto should be avoided for any cost,


That opinion is stupid. I take a gun to your head. I give you the
choice: Write a loop using goto's, and you live. Write a loop using the
for () statement, and you die. The cost is your life. Do you still think
goto should be avoided at any cost?
much like the opinion expressed by Dijkstra.


You are missing quite a bit of historical context.


Note the statement from the very article he linked: The exercise to
translate an arbitrary flow diagram more or less mechanically into a
jump-less one, however, is not to be recommended.

That seems to be conceding that some uncommon constructs are better
expressed with goto than with the available structured flow control
statements [which haven't really changed in all those years, with the
sole exception (NPI) of try/catch]
Jan 25 '06 #10

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

Similar topics

30
by: Hayri ERDENER | last post by:
hi, what is the equivalent of C languages' goto statement in python? best regards
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...
52
by: Rick | last post by:
Hi, For portability, can an issue arise if we use while(1) for an infinite loop in C? If so, should we then use for(;;)? Thanks, Rick
45
by: Debashish Chakravarty | last post by:
K&R pg.66 describes two situations when using goto makes sense. Has anyone here come across situations where using goto provided the most elegant solution. --...
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...
59
by: raashid bhatt | last post by:
why are GOTO's not used they just a simple JMP instructions what's bad about them
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.