comprehensive-rust icon indicating copy to clipboard operation
comprehensive-rust copied to clipboard

concurrency: Avoid `1..ROUND_NUMBER` loops

Open fw-immunant opened this issue 1 year ago • 1 comments

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.

fw-immunant avatar May 06 '24 17:05 fw-immunant

Sounds like a good fix!

djmitche avatar May 06 '24 18:05 djmitche