The use of goto in C

M

Michael Rasmussen

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?
 
V

Vladimir S. Oka

Michael said:
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...8ccde201d?q=goto&rnum=5&#doc_a17e1ee864889edb

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.
 
Z

Zara

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
 
?

=?ISO-8859-15?Q?=22Nils_O=2E_Sel=E5sdal=22?=

Michael said:
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.
 
C

Chris Dollin

Michael said:
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.
 
M

Michael Rasmussen

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:)
 
C

Chris Dollin

Michael said:
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.
 
C

Christian Bau

Michael Rasmussen said:
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.
 
J

Jordan Abel

Oh no, not again.


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?


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]
 

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

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top