procedure Touch(var Argument);
begin
end;
I included the above code in my blog a long time ago (2014 in fact: Delphi: always watch the compiler Warnings), but never got around to explain the why and how I got it, why it works and why it will likely work forever.
Background
Ever since the early Delphi days, there are three hints about “never used” of which the second often gets in the way during debugging:
- [WayBack] H2077: Value assigned to ‘%s’ never used
- [WayBack] H2164: Variable ‘%s’ is declared but never used in ‘%s’
- [WayBack] H2219: Private symbol ‘%s’ declared but never used
(note that these %s only hold for non-managed types, which I also addressed in Why don’t I get the warning W1036 Variable “‘MyStrings’ might not have been initialized”… and Delphi 10.3 Rio got released; I’ll wait a while hoping to see more positive comments).
Usually the compiler is right, but sometimes it is not: [WayBack] Check your compiler warnings and hints. They may still be errors. | Shiftkey Software Blog
So once every while, you need this workaround:
Solution
The solution is to have a method with one untyped var parameter (a var parameter without any type: this way you can pass any field or variable to it) that just does nothing. Often I included only at the place I need it as this single line fragment: procedure Touch(var Argument); begin end;.
Former Delphi compiler engineer and Borland Chief Schientist Danny Thorpe handed this solution, I think it was during or around his famous BorCon99 in Philadelphi (and later BorCon2005 in San Jose) Reading Tea Leaves: The Fine Art of Debugging talk. The talk is not-online, but luckily there are notes and a StackOverflow post:
- [WayBack] ANN: BDN News – October2005 – DeXter and the Developer Conference(s) 2005
- WayBack: Conferences » 2005 DevCon » IDE Abstract; Reading Tea Leaves: The Fine Art of Debugging
- [WayBack] c++ – My multithread program works slowly or appear deadlock on dual core machine, please help – Stack Overflow
- [WayBack] multithreading – Real World Examples of read-write in concurrent software – Stack Overflow
- [WayBack] c – Symbol eliminated by linker (Delphi) – Stack Overflow
- [WayBack] Thoughts from BorCon04 – Brad Abrams
- [WayBack] We Be Geeks, Ya – Danny Thorpe
The session had seemingly simple things like this [WayBack] Shenoy At Work: Set Next Statement in Delphi? with the picture on the right.
Voiding the solution
I’ve seen teams making this method inline, but that voids it. Usually they do not see it as they already resolved the “never used” problem in another way.





