rmcguire Wrote: > Justin Johansson <n...@spam.com> wrote: > > > Walter Bright Wrote: > > > >> When I originally worked out ideas for D, there were many requests from > >> the C and C++ community for a 'strong' typedef, and so I put one in D. I > >> didn't think about it too much, just assumed that it was a good idea. > >> > >> Now I'm not so sure. Maybe it should be removed for D2. > >> > >> Does anyone use typedef's? > >> > >> What do you use them for? > >> > >> Do you need them? > > > > Early on (2 months ago) when I was just getting into D I asked about > > typedefs > on this forum > > and some discussion transpired. > > > > http://www.digitalmars.com/d/archives/digitalmars/D/ > Is_typedef_an_alien_96658.html#N96658 > > > > (btw. There are a few responses from blasts from recent pasts in that > > thread.) > > > > Anyway, grepping for typedef over my current "scripting-language in D" > > project > source > > shows only old versions of my project using typedefs. Accordingly it looks > like I have > > since managed to convert *all* of my previous typedef incarnations to > > structs > so as to > > take advantage of struct's support for static opCall so as to synthesize > "constructors" > > (as well enabling use of struct methods). > > > > Maybe I didn't know enough about D back then, but the big problem with D > typedefs > > (for me at least) was there was no support for typedef constructors and > > code > otherwise > > blotted with cast-to-typedef-type is yuk in my way of thinking. > > > > I think there are only two sensible courses of action for D: support > > typedef > constructors > > (and methods???) or remove 'em. I'm not sure which option I prefer (is the > first even > > an option?) > > > > Cheers > > Justin Johansson > > > > > > I like typedef for making header files for c libraries. > For example, so that you can't just pass an int to a function expecting > an id.
Yep; I agree that's a good use for typedefs too .. but in the current D formulation, you still need to use a cast don't you?