Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×

Comment Re:why? (Score 2) 677

The reasoning behind not having multiple return statements is the exact same reasoning behind not using goto, so you're basically solving nothing here.

Also, the example given is a poor one, it has only one place where an error can be generated (which is not the case you should address with goto, instead, the case where you have lots of steps, each of which could fail is), plus, it doesn't have any real cleanup work to do (e.g. it's entirely reasonable to expect that you may need to deallocate buffers you were working with etc when you fail).

Comment Re:why? (Score 4, Insightful) 677

The problem is that the above is a remarkably simple case. The reality for a lot of cases where goto gets used for error handling is that with the above what you would end up writing is:

bool success = doSomethingThatMightFail();
if (success) {
        success = doSomethingElseThatMightFail();
        if (success) {
                success = doMoreFailingStuff();
                if (success) {
                        success = yepMoreFailingStuff();
                        if (success) { ...
                        }
                }
        }
}
if (!success) {
          cleanupWork
}

Meanwhile with a reasonably constructed macro to wrap his pattern, you end up with:
bool success = true;
CHK(doSomethingThatMightFail());
CHK(doSomethingElseThatMightfail());
CHK(doMoreFailingStuff());
CHK(yepMoreFailingStuff());

end:
if (!success) {
        cleanupWork
}

That's much easier to read, and just as safe.

Don't get me wrong, in a language where you can use exceptions for this, or better yet, the error monad, you should absolutely use those more abstracted concepts, but in plain C, this really is the best approach to handling errors in code where everything you do could go wrong.

Comment Re:why? (Score 1) 677

I'm intrigued, what do you think the "correct way" to do error handling in code where you have a whole sequence of actions where each can fail is? You have no exceptions, and you have no error monad, or good way to implement it either. Do you propose that you simply copy/paste the error handling and cleanup code everywhere?

What's the "right way" to do this in C that everyone else is missing?

Comment Re:Okay, so... (Score 1) 378

Then your argument has no usefulness to it. If you simply assert calories in minus calories out equals calories gained, you don't say anything that's useful to anyone. That's because calories out appears to be impossible to measure in its current state. It appears that bacterial fauna is a significant player in what makes up calories out, that's the point of this article.

Comment Re:Okay, so... (Score 1) 378

Congratulations, you didn't read the article. As you see, you are not the only thing digesting what goes in your mouth. It's entirely possible that said skinny person could consume 3500 calories, have their gut fauna convert 1700 of it into undigestible (by human) chemicals, and end up with a resulting actual digested intake of 1800 calories.

This is the point - you can not simply measure the number of calories that go into your mouth, you have to measure how many actually end up in the blood stream.

Comment Re:BS, with readily available proof (Score 1) 378

It may not be quite that simple.

1) After killing off the gut bacteria, the chemical balance of the gut may still favour those same bacteria re-growing
2) It may be that the presence of certain bacteria is what's necessary to lose weight (e.g. maybe there's bacteria that eat substantial amounts of your calorific intake and convert it to something undigestible), and it turns out that in this case the introduced bacteria out-competed these useful weight loss bacteria.

Comment Re:The biggest failure of science: (Score 1) 200

For men, it is true that the optimum weight/BMI* is "normal" and any increase is bad.

Actually no, overweight is the optimum. http://www.ncbi.nlm.nih.gov/pu...

People who are overweight are 0.94 times as likely to die as people who have normal weight. People who are slightly obese are 0.95 times as likely to die as people who have normal weight. People who are very obese are 1.29 and 1.41 times as likely to die as normal weight. Basically - being really heavy is very bad. Being a little on the chubby side is not.

Comment Re:HPV (Score 1) 740

The benefit is that there are many people who can not for one (legitimate, medical) reason or another receive the vaccine. By having a large proportion of the population vaccinated you stop the disease spreading and you protect even those who can not be vaccinated.

Basically, you do harm to others by not vaccinating (by allowing them to contract deadly diseases).

Slashdot Top Deals

"Only the hypocrite is really rotten to the core." -- Hannah Arendt.

Working...