3 ms·
> You might say “just search all the source code for that pattern” but this was two years before grep was invented! It was as primitive as can be. If you contr
by kazinator 7y ago
> You might say “just search all the source code for that pattern” but this was two years before grep was invented! It was as primitive as can be.
If you control the compiler, you can make the compiler diagnose all the cases which are affected by the precedence of &, emitting a file name and line number.
That was the thing to do with those several hundred kilobytes of code. Get the precedence right, and then warn about any code actually relying on the precedence. The compiler then "greps it out" accurately; even instances that are obfuscated by preprocessing.
Or, add the warning first before rolling out the change to the precedence:
foo.c:35: warning: obsolescent & precedence: use parentheses
Let the programmers go through a period of obsolescence whereby they rid their code of these warnings by using parentheses. Then, the compiler can be changed, while maintaining a diagnostic in that area of the language for some time. Eventually, when everyone has forgotten the old dialect with the bad precedence, the diagnostic can be removed.
When the new precedence is rolled out, a compatibility switch can be included for compiling code with the obsolescent precedence. Actually, that option can even be rolled out first (so it initially does nothing).
When the option is eventually removed, the compiler will refuse to run if it is specified.
So anyway, Ritchie had a few fairly easy and cheap alternatives to sticking with bad precedence; he perhaps wasn't aware of them.