Is there some elegant way of creating "isolated" types in D similar to the semantics of `subtype` in Ada.

Something like this

struct A
{
    this(int value) { this._value = value; }
    private int _value;
    alias _value this;
}

struct B
{
    this(int value) { this._value = value; }
    private int _value;
    alias _value this;
}

void main(string[] args)
{
    A a = 11;
    B b = 12;
    a = b;
}

except that

the final statement should error.

Reply via email to