Skip to content

Replace counter assignment with breaks#412

Closed
zlatanvasovic wants to merge 1 commit into
mrc-ide:masterfrom
zlatanvasovic:break
Closed

Replace counter assignment with breaks#412
zlatanvasovic wants to merge 1 commit into
mrc-ide:masterfrom
zlatanvasovic:break

Conversation

@zlatanvasovic

Copy link
Copy Markdown
Contributor

No description provided.

@weshinsley weshinsley left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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.

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

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

ozmorph commented Jun 22, 2020

Copy link
Copy Markdown
Contributor

@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