Let's go straight to the example. Let's say you write a DLL with 1 exported function. One of these functional parameters is an integer ...
procedure DoSomething(const Value: Integer); stdcall;
Now let's say that you have defined several constants to represent all possible integer values โโthat this function can recognize ...
const CON_ONE = 1; CON_TWO = 2; CON_THREE = 3;
Now tell me, when you implement this function, you really only need the first CON_ONE , but not the other two. Do you really want a hint of each of them?
A more realistic example are things like HKEY_LOCAL_MACHINE , HKEY_CURRENT_USER , etc. that come with Delphi (bound to Windows API calls). Just take a look at all the constants in Windows.pas . Imagine if all of these possible constants raised a compiler hint.
In fact, when you get a compiler hint for an unused variable, most often it means a coding error (or just something you forgot to delete), while an unused constant usually only means an unrealized opportunity.
Jerry dodge
source share