On Thursday, 18 February 2021 at 14:26:37 UTC, vitamin wrote:

Or combination of discriminate uninons and classes:

/+dub.sdl:
dependency "sumtype" version="~>0.10.0"
+/
import std.stdio;

import sumtype;

alias Expression = SumType!(
    ExprValue,
    ExprBinary,
    ExprUnary
);

class Expr{
    abstract Expression expression()pure nothrow @safe @nogc;

}

I don't see what this buys you compared to sticking with one or the other, but you are correct that it is technically possible.

Reply via email to