On 08/08/2012 15:47, michael.vancann...@wisa.be wrote:
On Wed, 8 Aug 2012, Jonas Maebe wrote:
(or is it possible?

After the body of the called routine has been parsed, it would be possible in theory (with indeed all the caveats the compiler would have to take care of such as side effects -- note that these may include non-obvious side-effects, such as potential overflow exceptions and invalid pointer accesses).

You'd need to check the caller routine as well, values for parameters might
still be used after the call to the function.

Dbg:=SomeCalculatingFunction+' Some message';

DebugLn(Dbg); // If debugln is empty, you don't need dbg for it, so the previous call is not needed.
In this case only the reference to the variable (but not the constant) would be dropped. So if the next writeln wasnt there, then the well known note "variable assigned but never read" would be given.

Of course this would not help the debugln, except the author could then place the string const directly into the call...

Writeln(dbg); // but you need it here.

And you don't know what SomeCalculatingFunction may have as side effects.
Yes, I did indicate that.
function calls can not be removed.
Again Except: if a special mode flag was introduced that could toggle this (default off). It is the same as with bool eval....


Of course, all highly theoretical.
I still use ifdefs for debug messages, and have a template to quickly insert :

{$ifdef debugmsg}SendDebug('|');{$endif debugmsg}

Yes, but it adds a lot of extra text to the source. If therce are frequent debugln calls.
- Either the debugln lines get very long,
- Or 2 extra lines are added for teh ifdef/endif and that stretches the length of the procedure, and how much fits on a screen

Of course the IFDEF does highlight in the IDE telling you where the debugln are.... But I already have the idea to allow highlighting user specified words (and then all debugln can highlight too)

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to