<div dir="ltr">On 17 July 2015 at 11:00, Bernd Petrovitsch <span dir="ltr"><<a href="mailto:bernd@petrovitsch.priv.at" target="_blank">bernd@petrovitsch.priv.at</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
<br>
On Fre, 2015-07-17 at 15:55 +0800, Navy wrote:<br>
[...]<br>
<span class="">> Goto is recommend in linux kernel programming, but it is despised in<br>
> many other situation. There are four rationable for using goto in<br>
<br>
</span>"goto" is (usually totally) forbidden for beginners/inexperienced<br>
programmers because some of us are old enough to have started<br>
programming with Basic on the C64 (no functions there - just "goto" and<br>
"gosub") and know what may happen in the long run if you write more than<br>
a hello-world.c ...<br>
My usual answer to "when may or should I use 'goto'" is: You will know<br>
when it's time - before that, simply don't use it.<br>
<span class=""><br>
> Documentation/CodingStyle. Do you have some viewpoints about "why<br>
> goto" or "why not goto"? I'm glad to get your point.<br>
<br>
</span>It mainly depends *how* you use it - see the patterns in the kernel for<br>
not so bad ones;-)<br>
And - as others wrote - rewrite the code without 'goto' and look into it<br>
after 3 months and decide which version is more readable/understandable.<br>
<br>
BTW that holds for all programming "style advices" (starting from "when<br>
should i factor out a function" over "how large should a function should<br>
be" and "too few or too many comments" to ...).<br>
It is like everywhere else: If the guideline is trivial to check, it is<br>
probably silly anyways.<br>
<br>
The big goal in (99,9% of) software development is: You want source code<br>
to be as easy to read and understand as possible - and nothing else!<br>
<br>
Coding style guidelines are just that: guidelines in that direction but<br>
never necessary nor sufficient to guarantee that (so the occasional<br>
violation for good reason - which one writes into a comment;-) - is not<br>
evil).<br>
<span class=""><font color="#888888"><br>
Bernd</font></span></blockquote><div><br></div><div>This is an interesting article about the history of goto being considered harmful; and how Dijkstra’s paper about it was misunderstood. <br><br><a href="http://videlalvaro.github.io/2015/02/programming-myths.html">http://videlalvaro.github.io/2015/02/programming-myths.html</a><br><br></div><div>Luis<br></div></div></div></div>