This shouldn't happen

bearophile bearophileHUGS at lycos.com
Wed Apr 25 13:18:18 PDT 2012


Andrej Mitrovic:

> Right, but the error messages will be awful, e.g.:
>
> struct None { }
> alias Typedef!None HWND;
>
> void test(HWND a, void* b) { }
> void main()
> {
>     test(null, null);
> }
>
> test.d(24): Error: function test.test (Typedef!(None,None()) a, 
> void*
> b) is not callable using argument types 
> (typeof(null),typeof(null))

In this case what error message would you like to receive?


> We can't just use Typedef!(void*) or Typedef!(int) because 
> -=/+= will
> be allowed, which shouldn't be allowed for handles. 
> const(void*) won't
> work either, because you should be allowed to assign one handle 
> to
> another and const forbids that.

What about creating a Handle struct with your desired semantics?

Bye,
bearophile


More information about the Digitalmars-d mailing list