lol I wasn't challenging you, and you kinda twisted my meanings (don't think on purpose), and still gave opinions....
using goto to simulate a loop doesn't make that any less likely. |
True, but doesn't make them more likely either...
You seem to suggest the for loop is more prone to you forgetting the ++i part -- but really, I think you're more likely to forget it with the goto approach. |
And I never hinted or said that loops are more error prone, just that both ways have potential
Nevermind that the goto approach is much more code, much less clear, breaks scope rules, and requires additional identifiers (what if you have more than 1 loop? Do you start naming them loop1, loop2, loop3?)
|
You added 14 more chars... and we still disagree, the code is much more clear to me. and when I name things I don't know for what it does, but why. so without reason for writing a multiple goto code, I couldn't tell you, but If i do I'll get back to you ;)
I think it's more that the code is written by you -- not so much that it uses goto. I could show you a tangled mess of gotos that aren't easy for anyone to read. |
anything could be written to be confusing, I make things stand out with comments when this happens. you comments in one line codes though... That is confusing!!! It's an opinion that I think most would agree with.
And while it's possible to have nested loops that aren't easy to read, they're less common -- and they're not "tangled" like gotos are. Loops have a clear begin and an end. Code always moves top to bottom. |
but so do goto(s)....
1 2 3 4
|
checkpoint: //<===start
inner: //<start
goto checkpoint;//<===End of checkpoint
goto inner; //End of inner
|
I suspect that goto is only easier for you because you're more familiar with it. That will change as you get more experience with loops.
|
Maybe you are right, but how does that make it more confusing? For me this is easier, for you that is easier... That has been my whole point.
My previous example of goto potentially skipping a constructor is a fact, not an opinion. That's a very real danger that anyone using goto must be aware of.
|
how would that error be worse than:
1 2
|
for(int i = 0; i < 5; ++otherVariable); // replace otherVariable with a reasonable typo
Foo();
|
my would bug out... Yours would pull an energizer bunny...
////////////////////////////////////
I make that joke at the end to show that I'm not trying to be a pain, and I appreciate the help and debate.
However, at the time in my programming I don't see you way being anything other than an opinion of a better way to do things.
int main()
{
I could eat a steak with my hands and mouth. but to someone that uses silverware that would be wrong.... Though in actuality it's not wrong, it's just different that your way.
I'm new to these forums, and I value tips and knowledge of other with higher skill sets, but I'll always challenge them if they don't make sense.
Given that I'm new and may one day look back and say "Oh crap I wrong", at this time, I seems more like you are saying, "Because this is easy for me, it's easy for all".
and looking at your code, it's nice and pretty and one line, I just don't like it. the following looks makes more sense to me, but like you said, ATM it's my pref so maybe that is why. I'll keep loops in mind, but I just don't see the point in confusing myself, only to make people stop watching me eat my steak
return 0;
}
;) but if you got tips even though I disagree, I'm all ears. I'm eager to learn this C-L, opinions aside.