Eric Sosman said:
jacob navia wrote On 07/10/07 08:40,:
... but since it *isn't* a character,
'A' could not possibly be thought of as character?!
Even if you 'know better', I can't believe the obviousness
of the expectation eludes you.
Note that C++ didn't make 'A' a char to support overloading.
That is incidental. C++ made 'A' a char because it's common
sense to think of and _use_ 'A' as a character. The
situation is no different in C.
you might just as well say its int-ness is inconsistent
with it being a struct tm.
If it had two distinct types simultaniously, I would say it
was inconsistent, yes.
The int-ness of 'A' may be surprising[*],
It is surprising.
but I can't think of any convention or practice elsewhere
in the language that establishes a pattern with which
it could be inconsistent.
Can you think of any convention or practice elsewhere in
the language that would established a pattern with which
'A' being a character would be inconsistent?
[*] Or maybe not, when you consider the usual
arithmetic conversions (6.3.1.8).
And why would making 'A' a character be inconsistent with
the usual arithmetic conversions? C++ programmers are no
more hampered in writing (*p - '0') than C programmers.
With the exception of sizeof, every operator[**] you
could apply to a char-type 'A' would promote its value
to int or unsigned int anyhow.
So let me turn that back at you. If it's going to happen
anyhow, again I ask, why would making 'A' a char cause
any harm?
[**] If I've overlooked something, I'm confident
someone will remind me.
Here's a question for you: If it's so obvious why 'A'
should be an int, why then does '\xfe' have no less
than 4 distinct possible values, depending on the
implementation?
C was designed for a purpose. Being a useful and
intuitive language for beginners wasn't one of them.
;-)