dmd 1.069 and 2.054 release

Adam D. Ruppe destructionator at gmail.com
Mon Jul 11 06:16:59 PDT 2011


Jonathan M Davis wrote:
> The deprecation messages are pragmas. They _can't_ give a useful
> line number.

My "solution" is to replace the pragma with a static assert(0) so
the compiler gives an error and call trace.

/home/me/d/dmd2/linux/bin32/../../src/phobos/std/string.d(885): Error: static
assert  (0) is false
arsd/web.d(575):        instantiated from here: tolower!(string)
[snip]


static assert(0) is actually my go-to replacement when things
start to go belly up, especially with templates. The list of
instantiated from here lines is a huge help when figuring it
all out.


Anyway, the pragma is meant to be informative and the assert is
an error. But, there's an easy "fix" for that too.

In std.string there's a softDeprec template. I think this is new
and it's private to std.string, but it's great because we can
add:

	version(scheduled_for_deprecation_is_an_error)
		static assert(0);

Thus:
===
private template softDeprec(string vers, string date, string oldFunc, string newFunc)
{
	version(scheduled_for_deprecation_is_an_error)
		static assert(0);
    enum softDeprec = Format!("Warning: As of Phobos %s, std.string.%s has been
scheduled " ~
===


And then you get a full error with details upon request.


(btw I keep putting fix and such in quotes because this is a filthy
hack!)


More information about the Digitalmars-d-announce mailing list