1620[jslint] Re: Filtered for...in
- Nov 19, 2010I agree with the OP.
I use the continue statement in exactly the same manner and have trouble understanding the objection to responsible use of the continue statement.
I just don't see where the continue statement can confuse logic where other flow control methods do not. I've personally gone nearly cross-eyed trying to deal with another developer's deep layers of nested flow control.
I do see how the continue statement can be abused, but I'm sure we've all seen how if statements can also be abused. Which is why I think that outright discouraging its use altogether seems rather extreme.
While I respect the difference in opinion, I'd also be glad to see an optional exception added for the unfiltered for..in check so that it could tolerate a single conditional statement block containing only "continue;" at the top of the loop's expression as a filter, but not tolerate for..in loops that are actually unfiltered.
--- In firstname.lastname@example.org, "Cheney, Edward A SSG RES USAR USARC" <austin.cheney@...> wrote:
> The problem with the continue statement is that its use obscures logic. It is clear that a loop will break or it is endless. An endless loop is considered a broken program. Since a correct loop will end what is important is if it ends at the defined point of termination or if the loop ends prematurely. The continue statement does nothing to make this more clear and instead confuses the interpretation of potential break points. The break statement, conversely, is absolutely imperative to this clarity. Premature loop termination is absolutely essential to certain operations where the variable representing the looping index is used in closure, because then that variable can be used against the stated loop length to derive conditional conclusions outside of a containing function.
> In other words the continue statement can always be mitigated through the use of more sturdy logic while its use can confuse other logic that is essential not open to mitigation. Therefore, it is in your best interest to not use the continue statement. Additionally, if you are assigning a variable set in closure representing any of the three object types in a condition containing a continue statement you are likely opening a covert channel in your code, which is a potential security weakness if your code is complex enough to contain multiple points of disparate execution.
> Austin Cheney, CISSP
- << Previous post in topic Next post in topic >>