3 ms·
I’m not debating why expressions are part of languages. I’m saying that I shouldn’t have to tear apart half the code just to make a change. And there are very
by makecheck 9y ago
I’m not debating why expressions are part of languages. I’m saying that I shouldn’t have to tear apart half the code just to make a change.
And there are very simple examples of that problem, right in the article:
1. Allowing the entire switch expression to bind to the same assignment makes it difficult to maintain when adding a case that will not perform that assignment. Now, instead of adding one line, you’re tearing apart half the block and trying to find a way to make equivalent new code.
2. Even adding a single line to a case may be impossible without rewriting the case. Given some 'case "Bar" -> 2;', the maintainer has to redo the entire thing: rewrite it as 'case "Bar":' with a colon, add 'break 2;' to preserve original behavior, and then add their stuff. That’s just broken; it won’t even produce a clean "diff" because you’re “changing” lines that don’t have anything to do with your new code. And you can bet at some point that somebody may just plain forget to add back the "break" when rewriting the expression needlessly, introducing a bug.