Let's jump straight into an example. Let's say you're writing a DLL with 1 exported function. One of those function's parameters is an integer...
procedure DoSomething(const Value: Integer); stdcall;
Now let's say you have defined multiple constants to represent all possible integer values this function might recognize...
const
CON_ONE = 1;
CON_TWO = 2;
CON_THREE = 3;
//Maybe hundreds
Now let's say when you implement this function, you only really need the first one CON_ONE
but not the other two. Would you really want a hint for every one of these?
More realistic example is things like HKEY_LOCAL_MACHINE
, HKEY_CURRENT_USER
, etc. which come with Delphi (tied 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.
Essentially, when you get a compiler hint of an unused variable, it most often means a coding error (or just something you forgot to delete), whereas an unused constant typically means just an unimplemented capability.