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

Reply via email to