Quote:Original post by Nytegard
You're all idiots for using C++. You're all dinosaurs for using C++. You should be using Java/C#/Enter your language of choice.
You're entirely right and I'm ashamed of myself.
but at least it's better than C and Java
Quote:Original post by Nytegard
You're all idiots for using C++. You're all dinosaurs for using C++. You should be using Java/C#/Enter your language of choice.
Quote:What is the right tool? It really depends. IMHO, it's not about what makes the code really maintainable, nor is it about how quickly I can write something. It's about the language I know best for meeting my requirements. If it's not a hobbyist program that I'm working on, it's about whatever tool that will pay my bills. I don't view it as what is the right (correct) tool, but what is the better of the tools at my disposel.
Quote:Original post by Lode
About the goto's:
Actually while converting C++ code to C, there's a situation:
In C there are no destructors, so whenever leaving a function you need to do the cleanup yourself first. I had a C++ function, that, on each error, does "return". Now I need to replace each return by "cleanup, return".
This is VERY tempting to instead put the cleanup at the end of the function, with a label in front called "error_cleanup:", and replace each "return" by "goto error_cleanup;".
Is the above use of goto justified? Making an extra function and giving all the things that have to be cleaned up as parameters seems not a good idea, lots of parameters and code duplication in that case.
Quote:Original post by cobru
take a peek at the linux kernel sources... in most places, you'll see exactly this mechanism (and since several people use it in several places, they can't be all wrong about it :D)
Quote:Original post by cobrutake a peek at the linux kernel sources... in most places, you'll see exactly this mechanism (and since several people use it in several places, they can't be all wrong about it :D)... it's very usefull to do cleanup like this in C, if you need to add "one more thing to clean" to the function, you just add it in the "error_cleanup:" part.
repeat:/*stuff*/if(....) goto repeat;
Quote:Original post by Lode
"fuck you all people who say goto's are evil, I use them to create my loops!"
Quote:Original post by Spoonbender
If you want to argue that using goto's like this is a good idea, you'll need better arguments than "lots of people do it". It might be true, but it doesn't really change whether or not it's a good practice.
Quote:Original post by Spoonbender
If you want to argue that using goto's like this is a good idea, you'll need better arguments than "lots of people do it". It might be true, but it doesn't really change whether or not it's a good practice.