So I had to use goto

Sometimes there are moments where someone comes screaming goto's are evil. Well, technology is never evil, just the evil person using it. But have you ever encountered a situation where the language didn't provide a certain control flow feature, so you actually had to use a goto to get a way round it? C is a great language and I love coding it. But the designers missed some parts that sometimes could be very nice to avoid a set of if's, like when you want to break multiple nested loops for example. I had this just a few minutes ago and remembered that was a goto statement in C which you can only find out by reading code where it's used - mostly kernel code, drivers and so on. Originally I found out about it while reading a gamebody emulator code which also some other things I found rather old-fashioned in idea and simply didn't find any use for it in my code. But it is there and I atleast with this when punching down someone's "goto is evil" screams. It's hard to explain people that certain things are not evil without an exact example. Reminds me of the typical scientist believing that nothing is right until god sucked his dick or he got an idea how to put it into formulas. However, I often had situations where an additional check was required cause the language didn't support direct jumping. From today on I shall consider goto as solution for things I can't formulate in the language's flow control set. Though I'm glad that everything was solvable without goto's... they can still be a tool to form professional garbage creators.

No comments: