Pattern matching + Enum proposals

It seems that comptime declarations and a single Variant type cannot provide this.

I don’t see any roadblocks. Here’s what I’d write, once struct extensions are implemented:

# Declares Color as an alias for Variant[Red, Green, Blue]
comptime Color = struct Red | struct Green | struct Blue

extension Color(Defaultable):
    def __init__(out self):
        self = Self(Red())   # delegates to Variant.__init__

This struct extension on Variant will be valid (i.e. satisfy the coherence rules) as long as Mojo adopts rules similar to those of Carbon. I posted info about Carbon’s rules here. (They were explained in a talk.)

Regarding alignment (@align): I’m not sure how it is modelled today, but I could imagine it also boiling down to a trait implementation.