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

concurrency: Avoid 1..ROUND_NUMBER loops #2060

Open
fw-immunant opened this issue May 6, 2024 · 1 comment
Open

concurrency: Avoid 1..ROUND_NUMBER loops #2060

fw-immunant opened this issue May 6, 2024 · 1 comment

Comments

@fw-immunant
Copy link
Collaborator

fw-immunant commented May 6, 2024

Teaching the concurrency course it sticks out as strange that many of the example loops start at 1 and continue to (exclusively) a round number, such as 1..5 or 1..10. This means we're comparing, for example, a loop in main that counts 1 2 3 4 with a loop in a background thread that counts 1 2 3 4 5 6 7 8 9: 4 and 9 iterations, respectively. I think it would be less distracting to loop for round numbers of iterations like 5 or 10, whether we start at 1 or 0. When I see a loop that starts 1 and has a non-inclusive end bound, my bug sense tingles, and I figure the same is probably true for a number of students; it's less distracting to do something more idiomatic as looping is not the focus here.

@djmitche
Copy link
Collaborator

djmitche commented May 6, 2024

Sounds like a good fix!

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

No branches or pull requests

2 participants