Why typedef's shouldn't have been removed :(

Steven Schveighoffer schveiguy at yahoo.com
Mon May 7 12:29:26 PDT 2012


On Mon, 07 May 2012 14:08:33 -0400, Mehrdad <wfunction at hotmail.com> wrote:

> On Monday, 7 May 2012 at 17:17:55 UTC, Steven Schveighoffer wrote:
>> Nothing in this whole thread seems to be very useful.  I don't know how  
>> else to answer your post except -- sorry, we're not going to change it.
>
> Okay.
>
> Though you'd be a lot more convincing if you could give an example of  
> how typedef was causing problems previously.

I think it was more that the whole concept was flawed -- typedef int myint  
never really did exactly what you wanted it to.

For example:

myint m = 1; // ok
m += 5; // ok
m = m + 5; // error?

Things got even worse when you weren't typedef'ing a basic type.  I think  
the advents in type construction in D2 have made typedef almost completely  
implementable as a library type, and we can do it the way it was  
intended!  Don't forget, typedef was there when we had no "alias this" and  
no blanket operator overloading.

When all you want is an opaque type that just can't be implicitly cast  
 from something else (such as HANDLE) typedef is a crude and inaccurate  
method to do that.

>> It's hard to see where you are coming from.  You have mentioned that  
>> doing Windows low-level programming is hard on most platforms except  
>> for C.  Well, if C made it easy, why not duplicate what they did?
>
> I don't understand your response or where you got that idea, but I don't  
> think my response would be very interesting even if I did...

Maybe it wasn't you, let me check...

http://forum.dlang.org/post/jnueti$1opd$1@digitalmars.com

OK, it was you, but under a different context, and I actually don't see  
you mentioning C there.  Sorry for the confusion/accusation.  I have a  
hard time keeping track of all these different threads in my head :(

>> 2) Make your own types.  You are free to not use standard/existing  
>> libraries.
>
> Yes, and I can write the rest of Phobos from scratch as well...

If it's better than phobos, then maybe we can use it!

Seriously though, I get what you are saying.  Fortunately, we have a very  
significant team working on phobos (I think more than a dozen people have  
commit rights), so the situation for "grr... phobos really should do  
*this*, but I can't get phobos changed" can be pretty readily resolved.   
Github and pull requests have made this incredibly easy.  I've looked at  
some pull requests that were dead simple, verified it in a matter of  
minutes, and click one button to pull it.  Even when I have no experience  
in the related modules.  Brad Roberts (and I think Daniel Murphy?) have  
set up an awesome testing system that automatically verifies pull requests  
on all the supported platforms using the latest from git.  See here:

http://d.puremagic.com/test-results/pulls.ghtml

The chances of your pull request being validated and pulled -- if it makes  
a good improvement to phobos -- are much much higher than they used to be.

-Steve


More information about the Digitalmars-d mailing list