K
Keith Thompson
Seebs said:But it can be used as one, since the jump from type-name to named type
is unambiguous.
No, a type-name cannot be used as a type. A type-name is the name
of a type, used to *refer* to a type.
Keith is a person. "Keith" is not a person. "Keith" is a name that
refers to a person. They are very different things. The question
How many letters are there in "Keith"?
makes sense, and has a definitive answer. The question
How many letters are there in Keith?
does not make sense (unless I've been going to the mailbox for lunch).
Right. And the thing is... If we can say that "int is a type", then we
can just as accurately say that "foo is a type". They're both actually
names that refer to a type, but it turns out that you can simply use the
type name to refer to the type when talking about code, just as you
can in the code.
Of course. That's what names are for.
It's like identifiers.
int x;
This declares a variable, x, of type int... but wait! Actually, x isn't a
variable; it's the name that identifies the variable. And it's not of
type int. It's of the type denoted by the name int.
x is a variable. "x" is its name.
int is its type. "int" is the name of its type.
(The quotation marks indicate that I'm referring to fragments of C
source code, not C string literals.)
But it's completely unconfusing to just say "x is a variable of type int"
instead of "the name x denotes a variable of the type denoted by int".
It's not
The name x denotes a variable of the type denoted by int.
It's
The name "x" denotes a variable of the type denoted by "int".
I would argue that the abstraction exists only during compilation, and
types don't exist at runtime.
Hmm. Ok, that's probably a fair point. Further thought may be required.
Ahh, but here's where we get into fuzziness. That entity's name isn't "int"
any more than it's "signed int". Or, after a typedef, "foo".
What? Why not?
That entity (a type) has multiple names: "int", "signed int", and "foo".
I think that's a thing which is only situationally important. I've
never before this conversation had any reason to say "the type which
is denoted by the name int" rather than "the type int". And, similarly,
I've never once needed the phrase "the type which is denoted by the
name size_t".
Ok -- but isn't this very discussion a situation where it's important?
I think it's not so much that there's not a distinction there, as that
you can pretty much ignore that distinction while programming, and you
only really need it when trying to explain the "under the hood" parts
of typedef. The rest of the time, "x is a variable of type int" is good
enough.
I agree that "x is a variable of type int" is good enough. My point is
that size_t and <something> (where <something> might be unsigned int,
unsigned long, or something else) *are the same type*.