Keith Thompson wrote:
)> Francois Grieu wrote:
)> ) On 2011/22/07 18:24, Kenneth Brody wrote:
)> )> Then I ask you, what's more important, avoiding "goto" or more efficient
)> )> code?
)> )
)> ) There is no general answer. And I don't need one, as my technique
)> ) avoids goto without any extra variable. Best of both worlds
)>
)> Except that your code doesn't avoid "goto", it just writes in a more
)> convoluted way that avoids the use of the literal string g-o-t-o.
)
) By that argument, all control structures are really gotos that
) don't use the literal string g-o-t-o.
I disagree. The technique the OP was using was nothing more than
disguising the goto as a continue or break, and disguising the jump
label as the closing brace on a do or switch block.
See below.
) Obviously people differ on how far they're willing to go to avoid
) "goto", but there are valid reasons to do so -- otherwise we'd be
) using backward gotos instead of loops.
What I'm arguing is that the OP is going way too far to avoid goto.
) Somebody, I don't remember who it was, argued that the label, not
) the "goto" statement", is the real problem. When you see a goto
) statement, you know what it does; just look for the correponding
) label and you know where the control is going to flow. If you see
) a label, you don't easily know how you got there; you have to find
) *all* goto statements with that label.
I agree. And in the case of the technique the OP used, it is even worse.
He is not only using a label, he is using a label that looks like a closing
brace.
) It's not what "disguised gotos" like "break" and "continue" do
) that's important, it's what they *don't* do. They don't branch to
) arbitrary points in the code, and they don't branch backwards.
)
)> Also, your technique is a lot less clear than just using goto.
)
) That's (obviously) a matter of opinion. If it's an accepted idiom
) (and I think it is in some circles), then it's perfectly clear.
I don't think anyone in this group recognized the technique, much less
found it an accepted idiom. This is the first mention of it being so,
and I wonder which circles it would be accepted in.
)> So, the advice is to just use goto in this case instead of trying
)> to adhere to 'never use goto' by the letter but not in spirit.
)
) By "the advice", you mean "your advice", right?
I used 'the advice' because others in this thread have been giving
the same advice, and therefore 'my advice' would be incorrect.
Apparently you take issue with this usage, but you don't explain why.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT