• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

#ActualÁlvaro

Posted 01 December 2012 - 03:35 PM

for (int bar =0; bar < 100; ++bar)
{
for(int foo = 0; foo < 100; ++foo)
{
if (foo * bar == 100)
{
foo = 100;
bar = 100;
continue;
}
}
}
printf("%d", 100);


So instead of a goto whose purpose is immediately obvious (you even get a label in whose name you can document what's going on), now we have code which expresses intent worse and requires changing the ranges in two places if they ever change. What if we now want to do something when the loops end without the condition ever being found? With the goto, you just put that code before the label; with the new code, there is really no obvious way of doing it. What if we are interested in knowing the values of foo and bar whose product is 100 beyond the loop? Again the old code was easier to adapt.

The only "advantage" of the second code is that it doesn't use goto, which as far as I am concerned is a ridiculous metric.

#1Álvaro

Posted 01 December 2012 - 03:34 PM

for (int bar =0; bar < 100; ++bar)
{
for(int foo = 0; foo < 100; ++foo)
{
if (foo * bar == 100)
{
foo = 100;
bar = 100;
continue;
}
}
}
printf("%d", 100);


So instead of a goto whose purpose is immediately obvious (you even get a label in whose name you can document what's going on), now we have code which expresses intent worse and requires changing the ranges in two places if they ever change. What if we now want to do something when the loops end without the condition ever being found? With the goto, you just put that code before the label; with the new code, there is really no obvious way of doing it.

The only "advantage" of the second code is that it doesn't use goto, which as far as I am concerned is a ridiculous metric.

PARTNERS