Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace counter assignment with breaks #412

Closed
wants to merge 1 commit into from
Closed

Replace counter assignment with breaks #412

wants to merge 1 commit into from

Conversation

zlatanvasovic
Copy link
Contributor

No description provided.

Copy link
Collaborator

@weshinsley weshinsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy that this one is equivalent to original code, but whether we want to do this might be a style guide/best practice issue.

I'm not sure whether 'break' always makes things clearer - if there's a lot of nesting of fairly lengthy loops (in terms of code size - which we have some examples of), then it's not always clear at a glance what is being broken, whereas setting the particular variable to break can be more clear, and to me doesn't seem like a terrible thing to do. (Noting that in the second example, which is still very simple, because of the two loops, we have to do both a setting of a loop variable and a break...)

@zlatanvasovic
Copy link
Contributor Author

In the second example goto would be more idiomatic. In the first it's clear since there is only one loop. I found the current syntax very confusing, as I had to re-check the initial loop conditions to see that it'd end.

The way that I proposed it the loop ends directly, instead of changing a variable and then checking its value to end the loop.

Copy link
Collaborator

@matt-gretton-dann matt-gretton-dann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to push #228 over this particular PR.

@zlatanvasovic
Copy link
Contributor Author

@matt-gretton-dann I'm missing something. In what way is that PR related to this? The lines that I changed here are untouched in it.

@ozmorph
Copy link
Contributor

ozmorph commented Jun 22, 2020

@matt-gretton-dann I'm missing something. In what way is that PR related to this? The lines that I changed here are untouched in it.

They may have accidentally been referring to my other PR #346 which (once complete) will remove the specified function entirely.

@zlatanvasovic zlatanvasovic deleted the break branch July 17, 2020 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants