More Clang diagnostic

Daniel Gibson metalcaedes at gmail.com
Tue Oct 26 05:58:22 PDT 2010


bearophile schrieb:
> Walter:
> 
>> Only because clang made a marketing issue out of it. Nobody coming from dmc++
>> noticed.
>>
>> I used to point out this feature in dmc++ to users. Nobody cared, I'd just get
>> blank looks. Why would I drop it if people wanted it?
> 
> Maybe it's all just marketing. But sometimes marketing is also a form of education, it teaches people a new way to do something, or why they should care about something.
> 
> Another possibity is that maybe the ecosystem around a language is changed, today more people use an IDE (especially people that don't use C/C++), and if you are using an IDE then maybe it is an useful feature.
> 
> Probably reality is a mix of those different possibilities.
> 
> 
>> Clang did have a nice idea with the spelling corrector. I implemented it in dmc
>> and dmd, and got flak for "wasting time" by adding it. I still like it, though,
>> and think it's an improvement :-)
> 
> In my opinion too it's an improvement. I presume some people have said it was a "waste of time" because currently there are more important issues/bugs in DMD.
> 
> 
> In the meantime I have underlined a second small idea from Clang that I think will be useful to implement in D/DMD too, the use of "aka", this is an example from Clang:
> 
> t.c:13:9: error: member reference base type 'pid_t' (aka 'int') is not a
> structure or union
> 
> 
> This is a wrong D2 program: 
> 
> 
> void main() {
>     alias int Foo;
>     Foo f;
>     f = f.x;
> }
> 
> 
> DMD 2.049 prints:
> test.d(4): Error: no property 'x' for type 'int'
> 
> But a more useful error message may be:
> test.d(4): Error: no property 'x' for type 'Foo' (aka 'int')
> 
> In a tiny program like that the difference doesn't show much, but as programs get bigger, and alias is more far from its usage, it will be useful.
> 
> The enhancement request:
> http://d.puremagic.com/issues/show_bug.cgi?id=5004
> 
> Bye,
> bearophile

It's not just the aka that would be really helpful here, but especially the "type Foo" instead of 
"type int".
Sometimes you have aliased types you use without really thinking too much about their real type, 
like FILE, socket_t and stuff like that.
So when you get an error-message talking about int or something and your code says socket_t it may 
be harder to find the error - especially when you have got multiple variables of different types in 
one line.
Of course getting information about types (the "logical" type like socket_t and the original type 
like int) in the error-message like in bearophiles "aka" suggestion would be the best solution :)


More information about the Digitalmars-d mailing list