[Freeciv-Dev] Re: (PR#6380) remove is_real and is_valid sanity variables
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Jason Short wrote:
> John Wheeler wrote:
>
>>[jdorje - Thu Oct 2 23:47:02 2003]:
>>>Most places in the code use this form:
>>>
>>> if (!normalize_map_pos(&x, &y)) {
>>> assert(0);
>>> }
[...]
>> I hate getting 'assert(0)' as an error message, because it
>>gives absolutely no indication what the problem is. What I'd much
>>rather see is something like:
>>
>> if (!normalize_map_pos(&x, &y)) {
>> die("Map position %d,%d not normalized.", x, y);
>> }
I agree assert(0) is very annoying. It is the sort of "nah, nah"
message that forces the user to do something everytime to figure out
why the program is complaining and usually with no access to the source
for the build or desire to figure out where it is or set it up. All
this when a minor amount of programmer effort once could provide all
the info required.
Something as trivial as 'assert(IS_REAL_MAPPOS)` with the corresponding
enum defined appropriately somewhere would make life much more pleasant
at such a point.
Die with a specialized local message is of course the creme de la creme.
> That would also work. I've considered turning this into a macro form in
> the past; something like
>
> #define normalize_real_map_pos(x, y) \
> if (!normalize_map_pos(x, y)) assert(0);
>
> which would make die a bit less clunky.
But clearly doesn't help John in anyway, and probably would encourage at
lot of unnecesary asserts and bad choices from coders that didn't catch
the subtle difference between the two nearly identical and rather
undistinguishable names.
> Although I'm not sure what you have against assert? It tells you what
> line the failure is on, which allows it to be easily tracked down.
>
> jason
Cheers
RossW
=====
[Freeciv-Dev] (PR#6380) remove is_real and is_valid sanity variables, John Wheeler, 2003/10/06
[Freeciv-Dev] (PR#6380) remove is_real and is_valid sanity variables, Guest, 2003/10/06
|
|