Is typedef an alien?

Jarrett Billingsley jarrett.billingsley at gmail.com
Thu Sep 24 12:33:38 PDT 2009


On Thu, Sep 24, 2009 at 2:36 PM, Aenigmatic <procode at adam-dott-com.au> wrote:
> No further response to any responses to my previous post's responses is a both swift and non-invasive.
>
> Now my deeply thought question is ...
>
> Is typedef (in D) a C/C++ legacy or is the dear orphan now adopted as a first-class citizen in the US of D?

It's a different beast, and in my experience, pretty useless. Most of
the time you want typedef'ed types to interact with other types a
little more richly. Say you want to use a double as a time. Okay, what
do you get when you subtract two points in time? Not a time, that's
for sure. You get a time _span_ instead. So you end up implementing
them as structs.

Virtually every time I've tried to use typedef, it hasn't sufficed and
I've ended up using a struct instead. It seems like a failed idea, or
at the very least, yet another half-thought-out abandoned feature.



More information about the Digitalmars-d mailing list