Using size_t clearly (appropriately?)

S

Stephen Sprunk

Mark L Pappin said:
English is strange.

"a" has many possible meanings, and which one is appropriate is
determined by context.

In the original statement (which I don't recall having seen other than
as the subject of dissection in this sub-thread), the writer might
have meant either "every" or "any". "any" makes the statement
trivially false (as you pointed out, 0 is a valid index and 'int' can
certainly hold that value); "every" makes the statement true.

As the writer of that statement, I meant it to mean "there exist potentially
valid array index values which will not fit in an int".

Now, if you know with absolute certainty that your program cannot generate
such values, then it may be safe to use int, but such assumptions often
prove untrue after the program evolves for several years.

Take, for example, the NASDAQ ECN protocol where trade numbers are
represented as six digits; that was considered far more than could possibly
happen within a day, but during the dot-com bubble there was a day where
over a million trades happened and every ECN and most broker systems crashed
and/or lost hundreds of thousands of transactions; it took days of manual
labor to sort out that and weeks to rebuild all the systems to handle a
rollover.

Most people are not creative enough to discern the difference between
"impossible" and "unlikely". Things which are "impossible" happen with
surprising regularity in the real world.

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

size_t, ssize_t and ptrdiff_t 56
size_t, when to use it? (learning) 45
return -1 using size_t??? 44
usage of size_t 190
size_t 18
ssize_t and size_t 8
What's the deal with size_t? 104
size_t in inttypes.h 4

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top