version(deprecated)?
Jonathan M Davis
jmdavisProg at gmx.com
Sun Nov 4 14:30:10 PST 2012
On Sunday, November 04, 2012 16:48:26 monarch_dodra wrote:
> I'm wondering if there is a way to know you are in deprecated
> mode or not?
>
> The deprecated attribute is great, because it gives a clear
> compile error (as opposed to a static if, which just hides the
> function completely).
>
> But the attribute alone is not enough: I have a class with a
> deprecated method, which consumes a book-keeping attribute: Not
> only will this attribute exist even though it has become useless,
> but the other functions will keep updating this attribute, even
> though it has no more consumers.
>
> What's more, I'd still want to unittest that function, but
> obviously, only when compiled in "-unittest -d".
Putting deprecated on the unittest block takes care of the unit testing
problem. However, without a version(deprecated), I don't know how you'd deal
with alternate versions of the same thing. Usually what happens in that case
is that you create an entirely new type or function with a different name.
Actually, if you use static if with __traits(compiles, blah) to check whether
the deprecated bit compiles, then you could do it without version(deprecated),
but it may be worth adding version(deprecated) just the same.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list