Commented Deprecated Directive

The deprecated directive, used to indicate a symbol is still available for compatibility reasons only, can now be followed by a string that will be displayed as part of the compiler warning. If you define a procedure and call it as in the following code snippet (from the MinorLang demo):

procedure DoNothing;

deprecated 'use DoSomething instead'; begi n end;

procedure TFormMinorLang.btnDepracatedClick(

Sender: TObject); begi n

DoNothing; end;

At the call location (in the btnDepracatedClick method) you'll get the following warning:

Wl000 Symbol 'DoNothing' is deprecated: 'use DoSomething instead'

This is way better than the previous practice of adding a comment to declaration of the deprecated symbol, having to click on the error message to get to the source code line in which this is used, jump to the declaration location, and find the comment.

Needless to say the code above won't compile in Delphi 2007, where you get the error:

| E2029 Declaration expected but string constant found

The new feature of deprecated is used rather heavily in the Delphi 2009 RTL and VCL, while I'm expecting third party vendors having to refrain from using it because of the incompatibility with past versions of the compiler, even if they could now use:

deprecated 'use DoSomething instead'; {$IFEND}

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment