On Saturday, 30 November 2013 at 18:16:23 UTC, Walter Bright
wrote:
On 11/29/2013 12:29 AM, Bienlein wrote:
I guess in D you would do something like this:
mixin template Rectangular() {
Point x, y;
}
mixin Rectangular;
struct Rectangle {
mixin Rectangular;
}
It's easier than that:
struct Rectangular {
Point x,y;
}
struct Rectangular {
Rectangle rectangle;
alias this rectangle;
}
D is always full of surprises ;-). Now the only feature in Go
that sets it apart from other languages is CSP.
I got this to work with help from the book by Ali Çehreli:
struct Point {
int x,y;
}
struct Rectangular {
Point x,y;
}
struct Rectangle {
Rectangular rectangular;
Rectangular rect() const {
return rectangular;
}
alias rect this;
}
void main(string[] args)
{
Rectangle rectangle = Rectangle();
rectangle.x = Point();
}