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

Michel Fortin michel.fortin at michelf.com
Sat May 5 06:01:07 PDT 2012


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.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list