4 ms·
{} are important signals that code can and will branch at those points. They’re fundamental to reading.
by hyperhello 4mo ago
{} are important signals that code can and will branch at those points. They’re fundamental to reading.
- quietbritishjim 4mo agoYou can use a different pair of symbols (or pair of words, like in Pascal, or whitespace, like in Python). There's certainly nothing fundamental about them. Also, even in C and C++, they don't indicate branching. You can place a brace block anywhere you can place a normal statement. You might use them in C++ just to delimit the extent of a RAII object. In C89 you might use a block to delay defining a variable until closer to its use, because variables can only be defined at the start of its block (although that no longer applies in C99). Conversely, though it's usually bad practice, you can use if statements and loops with individual statements.
- hyperhello 4mo agoI know it’s arbitrary and I know the symbol has been overloaded since they ran out of them, but at one time there was a certain economy and simplicity. < and > meant less than and greater than; { } were code blocks; even the semicolon was the right thing to use to break statements. I wish they had stuck to that kind of readability because I don’t know what C++ thinks it’s doing anymore.
- smcameron 4mo ago> I don’t know what C++ thinks it’s doing anymore. C++, when increment becomes excrement, decrement back to C.
- Ferret7446 4mo agoThat's like saying we could use a totally different set of runes than our alphabet. Yes, but why?
- fluffybucktsnek 4mo agoA pair of words requires more keywords (they also tend to be more verbose) and whitespace has ergonomy issues (specially with copy-pasting). Whitespace may come with intrinsic alignment, but formatting tools do short work of that.
- fanf2 4mo agoI don’t think there’s any branching in intitializer lists or declarations.
- hyperhello 4mo agoDon’t forget when they’re in string literals?