Re: maximum day of month

Tech-Archive recommends: Speed Up your PC by fixing your registry



No, I was not part of the "standard C" effort; while I was interested in becoming part of
the C++ standards process, I had no corporation to pay my way to the meetings. My major
concern was that some bizarre "exception" handler mechanism would be created; I had seen
so many *bad* exception handlers that the whole idea was scary. Then I discovered that
Jim Mitchell (Sun) was part of the standards committee. I knew I could trust him to not
allow some weird and incomprehensible exception mechanism to be created; Jim had created a
catch/throw mechanism for our LCC implementation back in 1967, and understood how
important it was and how to do it right.
joe

On Wed, 22 Jul 2009 09:26:50 -0400, r norman <r_s_norman@xxxxxxxxxxx> wrote:

On Wed, 22 Jul 2009 01:02:23 -0500, "Doug Harrison [MVP]"
<dsh@xxxxxxxx> wrote:

On Wed, 22 Jul 2009 00:31:32 -0400, Joseph M. Newcomer
<newcomer@xxxxxxxxxxxx> wrote:

Remeber that in the original C language, there was no "unsigned int"; instead, everything
was "int", which is why we have signed values to indicate string lengths ("I have this
string whose length is minus 7" does not actually occur...). So instead of having
unsigned int (or UINT) for a lot of values, we have signed values which are meaningless.

Well, strlen returns size_t, an unsigned type. For most programs, it is not
only exceedingly unlikely to have a string whose length can use the full
range of size_t (or even int), on most platforms, it is impossible. It is
normally sufficient to use int, and it's convenient for certain loop
patterns, e.g. while (--n >= 0). Using size_t to represent sizes is more
for "conceptual purity" than anything. Then there is ptrdiff_t, which is a
signed type intended to represent the difference between two pointers. But
given that malloc returns size_t, ptrdiff_t is typically insufficient to
represent the distance between 0 and size_t(-1), which is within the
theoretical range of malloc. So this was not particularly well thought out
by the Standard C guys. IIRC, they weaseled out by saying that a pointer
difference that can't be represented by ptrdiff_t is undefined. :)

size_t is a "new" addition to the C language. Kernighan and Ritchie
("The C Programming Language", 1978) didn't use it and both sizeof()
and strlen() had integer values back then. It seems to have been
added only with "Standard C", as shown in Plauger & Ritchie's book of
that name, 1989. I haven't bothered to look up just when Standard C
was adopted but I have a suspicion Joe may have been part of that
effort.


Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.


Quantcast