D's greatest mistakes
Simen kjaeraas
simen.kjaras at gmail.com
Mon Nov 29 17:08:27 PST 2010
Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
>> Which error message should I show?
>>
> I'm not sure what you're getting at. :)
[snip]
> But anyway it's just an idea and I'm probably missing something
> important, I haven't used D in a while..
I believe you are missing that more templates could bear the same
name, and they could all fail for varying reasons. In such a case,
do you print the error messages from 100 templates and let the
user sort through them, or do you show the error the compiler
currently shows?
I admit my example was flawed, or at least incomplete:
> void foo( A )( A a )
> constraint {
> isBar!A;
> }
>
> void foo( B )( B a )
> constraint {
> isQux!B;
> }
void main( ) {
int n;
assert( !isBar!int );
assert( !isQux!int );
foo( n );
}
The call to foo would match neither template, giving errors akin
to this:
test.d(15) Error: template instantiation foo!int failed.
test.d(3) Error: template constraint failed
test.d(6) Error: template constraint failed
Seems good for two or three templates, but I fear this would grow
quickly out of hand for more templates.
--
Simen
More information about the Digitalmars-d
mailing list