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

Mehrdad wfunction at hotmail.com
Sat May 5 11:20:44 PDT 2012


How do you fix it for size_t and uint, etc.?

On Saturday, 5 May 2012 at 13:01:08 UTC, Michel Fortin wrote:
> On 2012-05-05 05:02:44 +0000, "Mehrdad" <wfunction at hotmail.com> 
> said:
>
>> Now it's impossible to figure out whether a ParameterTypeTuple 
>> contains an HWND versus an HGDIOBJ or whatever...
>> 
>> this should really be fixed...
>
> It should be fixed indeed. Perhaps HWND should be defined more 
> like this:
>
> 	struct HWND { void *handle; }
>
> Or if you want it to implement some kind of inheritance scheme:
>
> 	struct HANDLE { void *ptr; }
> 	struct HWND { HANDLE handle; alias handle this; }
>
> That's still a lot better than typedef since you can control 
> what operations are allowed on the type. For instance, you 
> can't multiply two handles with the struct definition, with 
> typedef you could.
>
> My only fear is that this might not work play well with the C 
> calling convention (or Window's in this case). If that's the 
> case, then it's a good argument for having a separate language 
> construct.




More information about the Digitalmars-d mailing list