Proposal on improvement to deprecated
Jonathan M Davis
jmdavisProg at gmx.com
Mon Oct 3 08:18:33 PDT 2011
On Monday, October 03, 2011 15:01:13 Regan Heath wrote:
> We've already got informational warnings, warnings and errors.. why not
> just expand pragma to allow programmers to emit them on a case by case
> basis, i.e.
>
> pragma(info, "foo is scheduled for deprecation")
> pragma(warning, "foo will be deprecated on dd/mm/yy, replace with bar")
> pragma(error, "foo has been deprecated, replace with bar")
A key problem with using pragmas for deprecation messages is the fact that
pragma is run once when that code is compiled. So, if you want it to affect
only people who use the deprecated function, the function has to be templated.
So, anything which isn't templated, can't have a message. Also, it'll print
once per template instantion, not once per use, and it won't give any line
numbers (if it did, it would give the line number of the pragma, not where the
function is called). The pragma messages are somewhat useful, but they're too
general to work very well as deprecation messages.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list