Library Typedefs are fundamentally broken
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 22 17:13:19 PDT 2014
On Tuesday, 23 September 2014 at 00:01:51 UTC, Shammah Chancellor
wrote:
> What exactly was wrong with the original typedef statement that
> was deprecated?
I personally find it too inflexible; it virtually never does
exactly what I need. BTW I've never used std.typecons.Typedef for
the same reason.
But what are some examples of typedef? HANDLE and HMENU are close
to useful indeed, I've used typedef for that kind of thing
before. But it isn't perfect: do you ever want do do *handle?
That's allowed with typedef. Do you want it to explicitly cast to
void*? That's allowed with typedef.
People couldn't agree on if typedef should be a subtype or a
separate type either, which fed the deprecation. Personally
though I think that's silly, if what it does is well defined, we
can keep it and do other things for the other cases. But it does
need to be compelling over another feature to be kept and I'm not
sure it is.
So I tend to prefer struct and a little alias this and disabled
overloads to a typedef. A wee bit more verbose, but more flexible
and correct too.
More information about the Digitalmars-d
mailing list