Then in what sense is it either "created" or "a new type"?
Before it happens, "foo x;" is not a valid declaration, because foo doesn't
denote a type. After it happens, "foo x;" is a valid declaration, because
foo denotes a type. There was no type denoted by "foo" previously.
The only way I can make that make any sense is if you apply the
word "type" to the *name* of a type. As we've discussed, I don't;
the distinction between a name and the thing the name refers to is
particularly important in discussions like this one.
It seems less important to me, because "creates a new type which happens
to be the same as an existing type" seems sensical to me. It's just as
accurate to model it as "two types, which happen to be identical and/or
interchangeable", as it is to model it as "two names, for a single type".
Assume that size_t is a typedef for unsigned int.
Then I'd say that size_t is a type, and unsigned int is a type,
but they're *the same type*. If a type isn't distinct from other
types, then there's nothing new about it.
I'd say that they are two types, which happen to be the same. It's a new
thing, it just happens to be identical to an old thing. Here's the thing.
Once you've got all your headers included, then size_t is a type, and
unsigned int is a type, and they happen to be the same type.
But before that typedef was hit, size_t was not a type. The size_t type
has come into existence -- even though it's just a reference to another
type.
The distinction is in the name, because a type is not just a way of
representing data, but a mapping from a name to a representation of data.
Okay, jump over to UNIX for a moment:
$ echo "foo" > a
$ ln a b
The "ln" command here has created a link, not a file, but it's definitely
created a thing, and the thing it created turns out to have the same exact
semantics as the thing created by the first command, which definitely
created a new file. (Assume there wasn't already a file named a or b.)
Sure, it's actually creating a link, not a new file, but the effect is the
same as though it created a file -- you have a thing which is not distinct
in any way from a file, which is no less a file than the other thing, and
so on.
I think that's where some of this distinction comes from. I view an alias
as clearly a second-class citizen; more like a symbolic link than like a
hard link. You can tell that the alias is really not the same as the thing
it's an alias for. But, so far as I can tell, a typedef, once def'd, is
a full-fledged type which works like any other type name, so it's more like
a hard link.
My wife chose to change her last name when we got married. This did
not create (or even "define") a new person, merely a new name for
an existing person. (If she's a new person, it's only figuratively.)
This actually came up once in a game of Botticelli (the local name for
the game where you give initials and people try to guess who you're talking
about by asking yes/no questions). I gave the initials that one of our
friends would have in about two weeks... Now, the question is, was that
person alive? Fictional? Hypothetical?
I would argue that this action created a new *identity*, and I would view
types as more like identities than like people.
-s