Pre-RFC: Anonymous variant types

I think this is likely incorrect. It seems to me that what you've proposed here takes more work because it is more different; in particular, you need to change type, pattern, and expression grammars, and then you must also introduce the idea of positional variants. If instead you permit:

type Foo = A | B(String) | C { field: u8 };

// alternatively:

type Foo = enum { A, B(String), C { field: u8 } };
// but the former feels more "structural".

then you can reuse the expression and pattern grammars that already exist; you can also likely reuse the machinery of enums themselves much more (because they work with named variants...).

The impact on the language is also smaller.

4 Likes