by christiansakai · 5y ago · 0 comments
[1] https://nim-lang.org/1.4.4/manual.html#types
[2] https://nim-lang.org/1.4.4/manual.html#generics
[3] https://nim-lang.github.io/Nim/manual_experimental.html#conc...
(By the way, Rust lacks union types too, and it makes the language absolutely insufferable. Simply adding, say, a print statement as the last expression in one branch of an if statement changes that branches type, producing an error due to A/B type mismatches There is often no valid reason, e.g. in the case your branch isn't assigned to an expression. Even if it were, the type of that expression should be a union type: problem solved. It's so basic and so obvious, that Algol 68 got it right back in the 60s. Why on earth would you add discriminated unions but _not_ unions? It makes no sense.)
(I'm going to go off on a second tangent now: can we please just dust off the cool ideas in that language, like references represented in the type system, rather than replicating C++'s god-awful value categories and even _more_ reference squiggles? Consider how C++'s awfully complex [] move semantics could be expressed in that language!]).
[
] https://www.reddit.com/r/cpp/comments/ll2azr/move_simply_sut...