Getting the error from __traits(compiles, ...)
Justin Johansson
free at beer.com
Fri Nov 13 00:28:44 PST 2009
> > There are lots of ways you could provide such a concept-checker, but
> > they all require the basic ability to get the reason for the
> > __traits(compiles) failure.
> >
> > 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.
> >
> > --bb
>
> I think you might be asking for:
>
> static try {
> xxx;
> }
> catch( CompilerError[] errors){
> pragma(msg, "Failure in Frobozz!");
> pragma(msg, errors[0].msg);
> }
This is very interesting.
Given previous/recent discussion about scopes, should there be,
or are there, analogous static scope statements so that one could make
use of scope(exit), scope(failure), et. al. in a static context?
beers,
Justin
More information about the Digitalmars-d
mailing list