|
You need to tell the author he's in the wrong job. He needs to find something where logic and common sense isn't required. Management, maybe?
|
|
|
|
|
|
He would probably ace politics...
|
|
|
|
|
Not sure what it does, especially goto part. But reminds of person who skipped recursion class...
|
|
|
|
|
Without knowing the range of the for loops, and how many there are, I wouldn't recommend recursion, because it might overflow the stack.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Are you being ironic? Or do you actually think it's better to use nested fors explicitly, instead of passing a depth limit as a parameter of a recursive function?
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
0) If you need to specify a depth limit, you have problems elsewhere in the implementation.
1) It's impossible for us to properly evaluate the code without knowing much more about it. Right now, everyone's just throwing darts...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
OriginalGriff wrote: code review Sorry, what does that mean?
|
|
|
|
|
Did you mean
ep: return; to assuage those who believe a function should only return in one place?
|
|
|
|
|
The ep label is after the return statement, in the OP (pseudo) code.
|
|
|
|
|
That's why I asked. Jumping into the middle of a for loop makes no sense to me.
|
|
|
|
|
|
Looks like a fruity loops kind of guy
|
|
|
|
|
It comes from an old, working C++ project, which, in turn comes from an older, working C project, which, in turn, comes from an ancient, ugly, not-working assembly project.
|
|
|
|
|
The first and most important question - does it work?
The second question, how long ago was it written and what were the time-constraints and pressures of the project?
It's easy to stand there and criticize other peoples work. Pretty sure no matter what you produce code-wise there will be better ways to do it either now or in the future.
I never understand why people feel the need to post things like this - I'd guess some underlying insecurity issues...
|
|
|
|
|
Apparently so, in C++. In C# (his target language) no - the label is out of scope of the goto.
It was apparently written in 2006 ... and in my opinion you shouldn't try to perpetuate code crimes into new languages.
To be honest, any coder who thinks nesting loops 5+ deep is a good idea probably needs a lesson in exponential growth ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Ooh, I thought C++ initialised variables to 0 by default - apparently not. So this is undefined behaviour if any of the loop variables are used after the goto is executed. Fnu
|
|
|
|
|
Certainly not. What would the loop variables be set to when you jumped into the middle of the loop?
You can sort-of mimic something similar with an async method, by putting a yield return; in the inner loop. But IIRC, the compiler has to rewrite that as a state machine, because jumping into the middle of a loop just doesn't make any sense.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I review my own code - so I suppose, if I wrote it, it would pass.
But I didn't - looks more like something one of our overseas contractors would do.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
It's this new cool style of programming named For-Oriented Programming, or FOP for short.
I think I'll try it out on my next project
|
|
|
|
|
Sander Rossel wrote: For-Oriented Programming, or FOP
|
|
|
|
|
raddevus wrote: Sander Rossel wrote: For-Oriented Programming, or FOP
Or For Loop Oriented Programming - guaranteed to be a complete FLOP
(Yes, I know FLOPS is already an acronym in computing for Floating Point Operations Per Second).
|
|
|
|
|
Would be a good candidate for The Weird And The Wonderful forum, rather than the Lounge.
I'm surprised it compiled. Shouldn't 'ep;' be 'ep:;'? I don't know since it is 43 years since I last wrote a goto statement (excluding for old languages that needed 'ON ERROR GOTO ..', and that was as recent as the late 1990s).
modified 8-Oct-20 7:39am.
|
|
|
|
|
Quote: I'm surprised it compiled. I strongly doubt it compiles.
|
|
|
|
|
First thoughts: It does not look very performant with 4 nested for loops, but it might be necessary, so need more information before commenting any more.
Blink twice thoughts: Nuke that goto. Nuke it from space...
This should not compile in C#.
Wouldn't that have undefined behaviour in C, as the loop variables would not get initialised?
It looks like the code that the goto label refers to is only executed from the goto, so perhaps the goto could be replaced by moving that code into the if statement.
Good luck untangling this code.
|
|
|
|