Re:C – Preliminary C2x Charter
by alexhutcheson on Thursday March 17, 2016 @11:26AM
(#11304909)
For your first case, why not:
Not trying to be snarky, I'd just like to understand :)
[ Parent
| on HN ]
Because it's often either like this:
do {
const bool flag = do_something();
do_something_else();
} while(!flag);
Or like this: do {
int whatever = get_some_data();
const bool flag = do_something(whatever);
} while(!flag);Someone mentioned this instead:
while (true) {
const bool flag = do_something();
if (!flag) break;
}
Is it not what grandparent wanted?Yes, that would do it. It would just be nice to have it be better supported in the language rather than working around it like this. Any time you introduce break or continue into a loop you're making it more difficult to follow what's going on, since suddenly the exit condition can be anywhere. Not a big deal, especially if there's only one and it's right at the end, but mildly annoying that it can't be expressed more naturally.