"Trevor" <> writes:
> "Keith Thompson" <kst-> wrote in message
> news:...
>> Would you consider offering any kind of *constructive* suggestion?
>
> You can start by giving typedef some teeth, or replacing/augmenting it with
> something stronger.
> As it stands, typedef has about as much force as Hungarian Notation.
Just how easy do you think that would be?
Giving typedef "some teeth", assuming you mean having it actually
create a new type, would break existing code, so that's not an
option.
As for adding a new feature, say "newtype" that's similar to typedef
except that it creates a new type rather than an alias, I wouldn't be
opposed to the idea, but nailing down the semantics wouldn't be easy
(perhaps you missed the recent lengthy thread). Would a "newtype"
for a numeric type be implicitly convertible to other numeric types?
If so, there's not much point (the difference would show up mainly
in the presence of pointers to the new type); if not, that's a
fairly radical change to the semantics of arithmetic expressions.
And you still couldn't use the new feature for existing types in
the standard library (size_t et al) without breaking existing code.
As for struct types, well, we already have the ability to create a
new incompatible types just by declaring a new struct type. Arrays?
Pointers? It's already not clear that typedefing them is a good
idea; a "newtype" feature wouldn't necessarily change that.
In practice, most C programmers manage to use typedefs correctly,
treating them *as if* they were distinct types. I don't claim this
is an ideal situation, but there doesn't seem to be much pressure
to add a new feature to the language.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"