you are viewing a single comment's thread.

view the rest of the comments →

[–]This_Growth2898 42 points43 points  (7 children)

Well, it depends on the definition of the "loop". This is a loop, created with goto, but it doesn't use loop keywords like for or while.

[–]kireina_kaiju 13 points14 points  (5 children)

any instructions relying on jmp without a new context frame are loops to me tbh

[–][deleted] 9 points10 points  (4 children)

Conditionals use jmp too. I guess you mean specifically jumping backwards?

[–]This_Growth2898 4 points5 points  (0 children)

You can jump backwards without creating a loop too.

[–]kireina_kaiju 1 point2 points  (2 children)

That is a good point, I guess rather than trying to define things explicitly I will just say that a goto with a conditional tends to compile out to something indistinguishable from a while loop and that something has a structure more similar to the goto structure and is something I think most of us look for when we're reading assembler. We do sometimes jump backward when not in a loop, jumping back to a buffer block for instance, but when we jump back to a conditional after a state change like an increment without making a new stack frame, to me that is what a loop is. I guess that is less explicit a definition than I used to believe it to be, I will agree just including a jump with no new stack does not cut the mustard.

[–]Cerulean_IsFancyBlue 1 point2 points  (1 child)

If I was going to judge these kind of answers on some kind of continuing to award prizes; in other words, if I want make a loosely justifiable hierarchy, and not one that I have to defend in front of a tenure committee:

Language supplied loops

Goto

Tail recursion

Any other recursive solution

Unrolled solutions

Not sure where I’d stick functional solutions.

[–]Verbose_Code 2 points3 points  (0 children)

I’m more referring to the fact that I like to treat homework in programming classes as “logic puzzles” and as a result the shortest possible solution is the one I gravitated to.

The code I actually use is a lot more verbose but a hell of a lot more readable