Subject: [boost] Suppression of implicit conversions - was [1.44][Serialization] fails to compile on OSX universal
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-08-21 17:15:27
Emil Dotchevski wrote:
> On Sat, Aug 21, 2010 at 10:08 AM, Robert Ramey <ramey_at_[hidden]> wrote:
>> int id;
>> if(id == original_id)
>> special_type id(... ah think about this - this is a good thing);
>> if(id == original_id)
> Yes, we have user-defined types in the language to define custom
> behaviors in case the semantics of the built-in types are inadequate
> or incomplete. But whether such a change is a good thing can not be
> argued in the abstract, each case is different.
This discussion has go about as far as it can without getting to
specific cases. And there is a case to support any point of view
>I bet that sometimes
> the feeling of satisfaction we get when we see no warnings at all at
> the highest possible level gets in the way of our good judgment.
I think I accidently hijacked the thread.
I originally looked into this with the idea of suppressing the warnings
basically because I got tired of people bugging me about them. I'm thinking
the "the warnings are just BS since the code is correct" and people are
just to lazy to filter them out when the look at the error messages - and
btw -they were all in the library build anyway. So I started off with
sort of a bad attitude. I started thinking about the best way go get
people to stop bugging me without mucking up my code with a
lot of "warning hiding" code. As I started looking carefully at
this I found that, in my case at least, many/most of the messages
were related to implicit conversions between "similar" types so I
resolved to eliminate these. It started out as sort of an experiment
but as it progressed I realized that by addressing this in the way
I outlined about, I was actually making the code better in every
way. An the best part was that it didn't require too much of my
steadily atrophying brain power to accomplish. When I restricted
the type conversion - all the questionable cases showed up as
errors. Then it was easy to decide to either change the code
provoking the error and/or add another explicit conversion
to the type.
So the final result
a) traps more errors when I introduce them
b) eliminates warnings
c) makes the code easier to read by replacing "int" with the name
of a specific type.
d) was easy to implement
I'm not disagreeing with you. I think that adding
"warning hiding" code is a bad idea. I think that one can
leverage on the type system to improve the code and
elminate most of the warning as a side effect.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk