On Monday, 15 July 2013 at 18:26:26 UTC, JS wrote:
Original I had it as a class. I'm not sure if it matters much
between a class and a struct though?
It does matter a lot. structs are value types, classes are
polymorphic reference types. There is a nice summary table in
docs: http://dlang.org/struct.html , please notice that
"inheritance" and this "final" applies only for classes.
In any case, I solved this problem by using an attribute to
test instead of using isMutable. Obviously this requires adding
a symbol but not a huge deal.
e.g.,
@Enum immutable struct ...
and hasAttribute(T, Enum) replaces isMutable(T).
Yeah, that may work, despite being not that pretty. I personally
think it is better for now chose some not-that-elegant approach
in your code, at least until enums will become more robust.
Currently it tries to workaround some very basic type system
assumptions, which rarely ends good.