On Friday, 30 August 2013 at 15:41:55 UTC, Namespace wrote:
I believe typedef was deprecated due to no-one being able to agree on the semantics (although it's a bit before my time). I think it needs to come back as a very simple concept:

A type duplication. e.g. typedef int myInt; (or typedef myInt = int;) creates a new type that is exactly identical to int, but is a distinct type in the type system.

It should provide *exactly* identical behaviour to e.g. having two structs with identical contents but different names. E.g.

struct A{}

typedef A tA;
alias A aA;
alias tA atA;
typedef aA taA;

assert(!is(tA == A));
assert(is(aA == A));
assert(is(atA == tA));
assert(!is(taA == atA));
etc....

It's a really basic feature that D ought to have.

I don't understand the difference to alias myInt = int;
Isn't it the same?

Typedef was useful not for poking around new type with same properties - new name of existing type, but for non-trivial default value:

typedef int myint = 1;

void main()
{
        myint my;
        assert(my is 1);
}

Alias does not provide this feature, so D hadn't become better with this depreciation (actually the opposite). Nor it had with delete operator depreciation for the replacement of destroy, which like in case with typedef, does not cover full old feature functionality (and functionality what destroy() does provide is useless in many cases). I consider both depreciations as mistakes.

Reply via email to