These things you're talking about, of which size_t is one example
and unsigned long is a distinct example, are very useful concepts.
But calling them "types" while discussing C just leads to confusion.
I don't think so.
7.17 Common definitions <stddef.h>
The following types and macros are defined in the standard
header <stddef.h>. Some are also defined in other headers,
as noted in their respective subclauses.
The types are
ptrdiff_t
which is the signed integer type of the result of subtracting two
pointers;
size_t
which is the unsigned integer type of the result of the sizeof
operator; and
wchar_t
which is an integer type whose range of values [...]
They're types.
You are using a term, "type", that has a well-defined meaning in C,
and applying it to a closely related but very distinct concept.
I'm calling size_t a type because the standard says it's a type.
A sufficiently clever and friendly compiler might make some effort
to recognize ltypes and issue optional warnings when distinct ltypes
are mixed. A conforming compiler *must* issue a diagnostic when
distinct types are mixed in certain ways.
Right. And that's the thing. You're assuming that types are inherently
distinct, but they're not in C. There are pairs of types which are not
distinct, but they're still both types.
I agree completely that it's important to keep in mind that size_t
and unsigned long are logically distinct. I just think it's equally
important to understand that they may or may not be distinct on
the language level.
On this, we agree.
I prefer to express it as "some types are not distinct", you prefer to
express it as "they may be of the same type". I think that the former
maps better onto the standard's language for types, typedef, and so on.
Consider the discussion of <stdint.h>. It "declares sets of integer
types." Interestingly, <stdint.h> is described as declaring these types,
while <stddef.h> was described as defining them.
Oh, man. Look at this one:
7.18, paragraph 4:
For each type described herein that the implementation provides,
<stdint.h> shall declare that typedef name and define the associated
macros. [...]
And then later, in 7.18.1.4:
The following type designates an unsigned integer type with
the property that...
Throughout 7.18, the standard appears to use "type" and "typedef name"
essentially interchangeably. 7.18.1.2 says "the typedef name
int_leastN_t", 7.18.4.1 refers to "corresponding to the type int_leastN_t".
I have a proposed statement that I think we can probably all agree on:
"The language in the standard to do with types, and whether it is types or
type names that are defined, or perhaps declared, does not achieve total
consistency and transparency."
It seems to me that the standard is pretty consistent in treating "type"
and "typedef name" essentially interchangeably, with "type X" clearly being
used as a shorthand for "the type designated by the typedef name X".
I am not sure whether this means I'm right, or only that my confusion is
shared by others.
-s