2 ms·
As much as I think the fact that assignment in C returns the value causes barbaric illegible code, c programmers seem to love it C doesn't have all the nice su
by cygx 12y ago
As much as I think the fact that assignment in C returns the value causes barbaric illegible code, c programmers seem to love it
C doesn't have all the nice sugar that comes with newer or more high-level languages.
Sure, it would look nicer if we were able to write things like
for (char cc : stdin.chars) { ... }
for (string : iterator(env)) { ... }
But that's not an option, so we make do with what's available:
for (int cc; (cc = getchar()) != EOF; ) { ... }
while ((string = *env++)) { ... }
Assignment expressions are crucial for that.
- readerrrr 12y agoFor me, one of the advantages of C is that it lacks syntactic sugar. Writing a couple of extra characters is an acceptable tradeoff. Keeping it as simple as possible, with as few operators and keywords, is better.