|
|
|
|
|
by cmrdporcupine
1117 days ago
|
|
I think the original comment's point is exactly that. But people see the new expression type and want to apply it in this case. I'm of two minds on this. I can see the impulse and why you'd reach for it: Block lexical scopes with no if/while/etc statement attached read a bit odd. Introducing an "unattached" block means as a reader/reviewer I want to know why the scope has been created. So in this new syntax I suppose makes it "clearer" (in some respects) that what is being done here is introducing a new lexical scope specifically for the given variables. Like I commented elsewhere, this is somewhat similar to the ML-languages "let <assignments> in <block>" syntax, which I have always found admirable, as it makes clear to the reader (and compiler) what scope and state are being dealt with. On the other hand, this is so out of step with C/C++ style generally, and it seems so excessively "clever" that I think it's going to piss people off. And because it's bolted onto the conditional expr, you get the pointless ;true there. Having a with ( ... ) syntax would have been nicer? with (auto [a, b, c] = std::make_tuple(x, y, z)) {
}
I'm curious what Titus Winters and the Google C++ style guide is saying about this. |
|
Having said that: It's not really unlike C++, since you have it in for loops:
which is like anyway, I wouldn't mind the syntactic sugar of "with X=Y do Z" or "let X=Y in Z"