I find structs completely superior to classes as design base and only resort to latter if find myself in need of polymorphic behavior. There is an issue of bad constraint error messages but that is exactly that - implementation flaw that needs to be fixed, not a conceptual flaw.

Mostly agree with Jakob have said, few extra tips:

1) you can use `foo(T : Stuff)(T t)` instead of `foo(T)(T t) if (isImplicitlyConvertible!(T, Stuff))`

2) You can extend structs no only with UFCS but also via `alias this`:

struct One
{
    void foo() {}
}

struct Two
{
    private One one;
    alias one this;

    void bar() {}
}

void main()
{
    Two two;
    two.foo(); two.bar();
}

Aliasing members as this can be considered a form of single inheritance in this context.

Reply via email to