Is there an easy way to mimic generics with an accept method of a visitor pattern?
Paul Backus
snarwin at gmail.com
Thu Feb 18 14:43:43 UTC 2021
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.
More information about the Digitalmars-d-learn
mailing list