(For callbacks etc., once we have an accepted mechanism, such as `Discard', one can just as well add it immediately.)
One thing that would be good, and generally is not done, is to generate a hint/warning/error in the case where you specify that a parameter is unused, but then in fact use it (since this likely indicates either an error or at the least obscure code indicating one thing and doing another).
Metrowerks Pascal has the concept of notes which I guess are akin to the hints suggested here.
In my thinking, I would say anything that the compiler cannot compile should be an error, anything that is quite likely an error, but the compile can compile it (generally something that could be legal in at least some case), and anything that is just the compiler trying to help you clean up your code would be a hint.
I generally do not compile with -Werror, as I often use warnings to remind me of things I have not yet done and so they might stay in the code for a week while I'm working through putting structure in the code before filling out details. But I loathe warnings and strongly believe code should compile properly without any warnings as the normal case, which is why we need strong, precise control over turning off warnings where appropriate.
To my mind, the cleanest way in GPC is attribute (unused) on the formal parameter, but one down side of this is I don't believe GPC allows you to specify that in only the implementation (for example, if I have a unit:
interface function doit( a: Integer; b: Integer ): Integer; implementation function doit( a: Integer; b: Integer attribute (unused) ): Integer; begin return a; end;
That would not be possible in GPC would it? This case might occur in a unit (or set of units) that provides a set of functions all with the same parameters (perhaps a set of callback functions that do different things).
Obviously, the easiest thing for me would be just to implement the {$unused(b)} directive, but whatever solution, I don't really care as long as I can make it work.
Enjoy, Peter.