Ada-Style Sub-Typing
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 2 13:16:42 PDT 2015
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.
More information about the Digitalmars-d-learn
mailing list