Timeline for What are the pros and cons of having do ... while loops?
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 11, 2023 at 18:38 | comment | added | dan04 | @SilvioMayolo: It would be difficult to add foreach loops to C itself because C doesn't really have arrays, just pointers in trench coats. | |
Jul 8, 2023 at 20:08 | comment | added | Silvio Mayolo |
@xigoi On the contrary I'd argue C-style for loops should also go the way of the dinosaur. Python did it right: for -each loops are the norm, and you have to use while for anything complex.
|
|
Jul 8, 2023 at 19:47 | comment | added | xigoi | @SilvioMayolo C-style for loops already evaluate the third part of the header at the end and it doesn't seem to confuse anyone. | |
May 19, 2023 at 6:04 | comment | added | springogeek |
There's an interesting ergonomic benefit to the do while (condition) { code } syntax. If the programmer decided they need to switch from while to do-while, it's a 3 character change. Re-arranging the do-while in other languages is significantly more effort.
|
|
May 16, 2023 at 19:16 | comment | added | rydwolf |
@SilvioMayolo Not necessarily, you just need to change how you think about it from "evaluate the condition at the end" to "a normal while loop where you run the block an extra time at the start"
|
|
May 16, 2023 at 19:06 | comment | added | Silvio Mayolo | @RadvylfPrograms Putting the condition in front and evaluating it at the end seems like a huge recipe for footguns. | |
May 16, 2023 at 18:57 | comment | added | rydwolf |
Perhaps do while (condition) { code } would be a way to get around this? Could be more easily confused with a normal while , tho
|
|
May 16, 2023 at 18:53 | history | answered | Ginger | CC BY-SA 4.0 |