> Pascal did not have sum types because Wirth thought they were less flexible than untagged unions
I'm not sure whether my dream language would have tagged or untagged unions (Scala 3 has both it seems). I'd be interested if anyone has any further points of comparison beyond:
Tagged unions, eg. in Rust: enum Tagged {A(i64), B(String), C(f64)}
Untagged unions, eg. in typed Python: Tagged = int | str | float
Tagged unions are better as you can represent duplicated types and types with no data, eg: enum Tagged {A, B(f64), C(f64)}
Untagged unions are better as you can willy nilly create new subsets and intersections of types. I find often in AST-ish work I want to express eg: def f(x: A | B | C) -> A | B
> Pascal did not have sum types because Wirth thought they were less flexible than untagged unions
I'm not sure whether my dream language would have tagged or untagged unions (Scala 3 has both it seems). I'd be interested if anyone has any further points of comparison beyond:
Tagged unions, eg. in Rust: enum Tagged {A(i64), B(String), C(f64)} Untagged unions, eg. in typed Python: Tagged = int | str | float
Tagged unions are better as you can represent duplicated types and types with no data, eg: enum Tagged {A, B(f64), C(f64)}
Untagged unions are better as you can willy nilly create new subsets and intersections of types. I find often in AST-ish work I want to express eg: def f(x: A | B | C) -> A | B