Programming language development has essentially ceased, no? Because now that you have a super powerful, ceaseless special interest personality that can be ordered to be specially interested in any problem. The actual problem - a dearth of things that special interest personalities will do for little to no money - has been solved.
fn six_numbers() -> (u8, u8, u8, u8, u8, u8) {
(10, 20, 30, 40, 50, 60)
}
fn in_an_array() -> [u8; 6] {
[10, 20, 30, 40, 50, 60]
}
The return type must be sized, because otherwise how can we put that anywhere? But of course your answer can just be to put it on the heap inside a Box... fn heap_numbers() -> Box<[u8]> {
let mut slice = Box::new_uninit_slice(6);
slice[0].write(10);
slice[1].write(20);
slice[2].write(30);
slice[3].write(40);
slice[4].write(50);
slice[5].write(60);
unsafe { slice.assume_init() }
}They allow for types like "String or Integer". A function which returns a value of type "A" can automatically also be assigned to a variable of type "A or B", and a function which accepts a parameter of type "A or B" can automatically also be passed a variable of type "A". This is not the case for algebraic sum types, which require somewhat inconvenient wrapping or unwrapping.
Unlike algebraic sum types, set-theoretic union types are also not necessarily mutually exclusive. E.g. a number of type "Integer or Float" could be both. Moreover, set-theoretic types can be generalized to arbitrary Boolean combinations of types, e.g. "A or (B and not C)", possibly involving disjunctions, conjunctions, and negations (since {and, or, not} are functionally complete). That's not possible for algebraic sum/product data types. Though there is no mainstream language yet with a set-theoretic type system that supports negation types.
There's no mainstream language with negation types, but a few good research languages with them, eg MLstruct.
[MLstruct]:https://github.com/hkust-taco/mlstruct
This is cool. Unfortunately it's also too late now. The machines have taken over programming.