flag and variable, or variable w/ reserved value?
which is better?
all the time, i come across the "pattern" of a variable storing a value, and a boolean or reserved value saying whether its in effect or not.
or a boolean or reserved value indicating "none" or "N/A" or "don't care".
an example using a reserved value:
current_weapontype_ID_number // an object_type ID number, or -1 for none.
an example using a variable and a boolean:
dropped_object[n].data[0] // generic var. for travois: 0=not carried, 1=carried.
dropped_object[n].data[1] // generic var. for travois: ID number of player carrying the travois
other than the obvious fact that a flag requires a second variable, are there any advantages one way or the other?
i run into this "pattern" a lot, and use both methods. but i would like to establish a coding policy one way or the other.