"Trishia Rose" <ad********@yahoo.com> wrote in message
news:b2**************************@posting.google.c om...
God dang it all, i am so sick of programmers who feel compelled that
every single time they use an int variable, they give it some brand
new name!
IMHO, to add additional information to the interface and the user's code.
An int is just an int -- the type says nothing about what it represents. A
frequency and a time delayare both (unsigned) integers, but they represent
very different and distinct concepts.
Typedeffing distinct types gives the user of an interface additional
information:
* it makes function prototypes more descriptive
* it discourages the user from assigning between variables of those types
It may also provide additional information for tools: for example, PC-Lint
can be configured to treat typedefs of integral types as strong types and
warn on inappropriate assignment.
It can, as you noted, be taken too far: I tend to typedef for quanties of
distinct physical units (FrequencyHzT; DelayMsT; and TimeoutMsT is distinct
as it has special "immediate" and "infinite" values) but not for quantities
of things (size-of-buffer, read-count, number-of-sectors).
--
James Kew
ja*******@btinternet.com