Using Pragma Obsolescent

I stumbled on this link at the Ada reddit, and thought it was worthwhile posting here for posterity’s sake. I’m quite sure that at some point in the future I’m going to have a need for something like Pragma Obsolescent, so I might as well write it down to help my brain remember it.

So what is Pragma Obsolescent about?

This pragma is used to indicate that the named entity is considered obsolescent and should not be used. Typically this is used when an API must be modified by eventually removing or modifying existing subprograms or other entities. The pragma can be used at an intermediate stage when the entity is still present, but will be removed later. The effect of this pragma is to output a warning message on a reference to an entity thus marked that the subprogram is obsolescent if the appropriate warning option in the compiler is activated. If the Message parameter is present, then a second warning message is given containing this text. In addition, a reference to the entity is considered to be a violation of pragma Restrictions (No_Obsolescent_Features).

Nice! With this, people like me, who’re not so good at designing API’s correct from the get-go, can benefit from nice warning messages when we compile projects that depends on these fluctuating API’s. I like it a lot.

I think I need to take a closer look at the Pragma section of my Programming in Ada 2005 book for more gold nuggets like this one.