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