On Fri, 13 Nov 2009 00:00:42 +0300, Walter Bright
<newshou...@digitalmars.com> wrote:
Walter Bright wrote:
Bill Baxter wrote:
Any other thoughts about how to get the failure info? This is
probably the main complaint against __traits(compiles), that there's
no way to find out what went wrong if the code doesn't compile. Often
it can just be a typo. I know I've spent plenty of time looking at
static if(__traits(compiles, ...)) checks that weren't working only to
discover I switched an x for a y somewhere. Or passed the wrong
number of arguments.
I agree it's a problem. Perhaps we can do:
__traits(compiles_or_msg, ...)
which would print the error messages, at least making it easier to
track down.
Eh, scratch that dumb idea. Just remove the __traits(compiles, ...) and
replace it with ..., and you'll get the message!
He was asking for a string so that it would be possible to parse and/or
output. More like:
enum s = __traits(compiles_or_msg, ...);
static if (s.length == 0) {
// no error
} else {
// do stuff with error message
}