Darren New wrote:
> Christopher Smith wrote:
>> Darren New wrote:
>>> Gabriel Sechan wrote:
>>>> Note:  to get this absolutely right, use of typedefs is a must. 
>>> Actually, typedefs suck. What you really want is to be able to have
>>> multiple incompatible types, all identical to "int".  Why would I
>>> prefer
>>>
>>> typedef int HorizontalPixelCount;
>>> typedef int VerticalPixelCount;
>>>
>>> and make it so I could add those two together?
>> Come on, play fair guys.
>>
>> That would be a misuse of a typedef. A typedef is an alias, not a new
>> type.
>
> That's why they suck, yes. That's precisely what I'm saying. :-)  I'm
> not sure what's "unfair" about the observation.
You found one case where you'd have to be an idiot to use a typedef, to
solve a problem they aren't designed to solve, and are asserting that
they suck as a consequence.

I could just as easily demonstrate that inheritence sucks because if I
inherit Girl from Candy and Boy from Economics that I can't describe a
container that contains both Boy's and Girl's.

A trivial example where a typedef is useful would be the <cstddef.h> or
"value_type" ad "iterator" idioms found in the STL. I very much *don't*
want vector<T>::value_type to be a distinct type from T, nor do I want
to have to know whether vector<T>::iterator is really a T* or not.

--Chrs

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to