need clarification: will typedef, C struct initialization, etc.

Lionello Lunesu lio at lunesu.remove.com
Mon May 31 15:05:50 PDT 2010


On 1-6-2010 5:38, Andrei Alexandrescu wrote:
> On 05/31/2010 03:54 PM, bearophile wrote:
>> Andrei Alexandrescu:
>>> typedef is gone.
>>
>> *mewls* I have shown here some examples of typedef usage, and I'll
>> keep posting few more in future. I'd like to pull it back from the
>> grave and keep it :-)
> 
> It's wasted time. typedef is gone.
> 
> Andrei

:((

I also miss typedef. I thought D had a great opportunity to fix it.

Take something like the Windows headers. It mostly consists of typedefs
for handles and whatnot. Without typedef you'd have to use alias and
type safety is out of the windows.

So what would be the way to translate those Windows headers? Create a
unique struct for each old typedef? With alias this, and a ctor? Well,
if that's the way to do it now, why not make typedef a shortcut for
exactly that!?

IIRC typedef is gone because you and Walter could not agree whether it
had to be a subtype or a supertype of the typedef'ed type. For me it's
rather simple: I want to introduce a new type in such a way that it
helps me prevent mistakes, ie. passing one handle when the function
wants another, even though both are based on void*, or whatever.

Bring typedef back!

L.


More information about the Digitalmars-d mailing list