Clearer error messages - how?
Simen Kjaeraas
simen.kjaras at gmail.com
Fri Mar 21 14:53:28 PDT 2008
I'm playing around with templates and mixins of different types, in an
effort to
make a property struct with all manners of overloaded operators (as per
Alternative solutions to returning ref types. in digitalmars.D).
Now, when I use this thing and do something wrong, I get error messages
with
very user-unfriendly texts. For instance:
/////////////////
int _a;
property!(int, properties.read) a = &_a; // properties.read means only
operators
// that do not change the data are
overloaded.
a += 4; // this lines leads to the errors below
/////////////////
test.d(8): Error: 'a' is not a scalar, it is a
_property!(int,void,"+,-,*,/,%,&,|,^,<<,>>,>>>,~,in","+,-","")
test.d(8): Error: incompatible types for ((a) += (4)):
'_property!(int,void,"+,-,*,/,%,&,|,^,<<,>>,>>>,~,in","+,-","")' and
'int'
test.d(8): Error: 'a' is not of arithmetic type, it is a
_property!(int,void,"+,-,*,/,%,&,|,^,<<,>>,>>>,~,in","+,-","")
As you can see, hardly user-friendly. Now, how can I make them more
readable? Do
I need to overload all the other operators with templated functions with
static
asserts?
-- Simen
More information about the Digitalmars-d-learn
mailing list