ch-ch-changes

Daniel Keep daniel.keep.lists at gmail.com
Wed Jan 28 23:22:36 PST 2009



Nick Sabalausky wrote:
> "Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message 
> news:glqu65$15pi$1 at digitalmars.com...
>>
>> Christopher Wright wrote:
>>> Don wrote:
>>>> [snip]
>>>>
>>>> Then we get:
>>>> static assert(__traits(mixincompiles, comp), "Predicate: " ~ comp ~ "
>>>> does not compile");
>>>>
>>>> mxin(comp);
>>> That's certainly prettier.
>> Still doesn't give the user a reason for WHY their predicate didn't
>> compile...
>>
>> It's a pity we can't do this (or something similar):
>>
>> template Something(string comp)
>> {
>>    static assert( __traits(mixincompiles, comp),
>>        "Predicate q{"~comp~"} does not compile, because:\n"
>>        ~__traits(mixinerrors, comp,
>>                  Something.instantiationFile,
>>                  Something.instantiationLine) );
>> }
>>
>>  -- Daniel
> 
> I'd much rather see errors and static asserts inside of a template cause the 
> compiler to automatically output a template instantiation "stack trace" (for 
> lack of a better term). Ie, list files/lines starting with the deepest 
> file/line, and then the file/line that instantiated that template, and if 
> that was also inside a template, then the file/line that instantiated that, 
> etc. 

I'd certainly like to see better error reporting for template errors,
but I think the ultimate goal should be to be able to write template
that, when they do something wrong, can tell the user SPECIFICALLY what
they did wrong.

Error foo.d line 53:
  (*vomits template backtrace at the user for a page or two *)

-or-

Error foo.d line 53:
   Foo!("blah") expected an int, not a char[4].

  -- Daniel



More information about the Digitalmars-d mailing list