I'm a generalist developer, preferring to have some skills in a variety of areas to being really good at only a few. I need to see how a technology solves real problems to really understand it.
I find myself every now and then missing the loop-and-a-half construct where you need to do some preparation before testing the loop condition and this preparation needs to be repeated on every iteration. The syntax could be something like this:
do {
// Stuff
} while (condition) {
// More stuff
}
which already resembles the two existing loop syntaxes, while and do-while. So this would execute Stuff always first, and while the condition is true, it would execute More stuff, Stuff, and then test the condition again.
The way to accomplish this now is with an infinite while loop with a conditional break in the middle. I find this somewhat inelegant, and also harder to see that there is a condition that causes the loop to terminate.
I find myself every now and then missing the loop-and-a-half construct where you need to do some preparation before testing the loop condition and this preparation needs to be repeated on every iteration. The syntax could be something like this:
which already resembles the two existing loop syntaxes,
while
anddo-while
. So this would executeStuff
always first, and while the condition is true, it would executeMore stuff
,Stuff
, and then test the condition again.The way to accomplish this now is with an infinite
while
loop with a conditional break in the middle. I find this somewhat inelegant, and also harder to see that there is a condition that causes the loop to terminate.Can you give an example of when this would be useful?