4 ms·
My blame of Crystal is still lacking of discriminated union (like in Rust) and the hard to use macros system (while powerful) Other than that, it's powerful.
by revskill 3y ago
My blame of Crystal is still lacking of discriminated union (like in Rust) and the hard to use macros system (while powerful)
Other than that, it's powerful.
- rddbs 3y agoThere are union types, which despite being untagged might be enough in a lot of situations, and I believe has language support in things like switch statements. https://crystal-lang.org/reference/latest/syntax_and_semantics/union_types.html https://crystal-lang.org/reference/latest/syntax_and_semanti...
- yxhuvud 3y agoCrystal union types are tagged as the actual type a variable contains is tracked. I honestly have no idea how anything could work if they were not tagged. Like how on earth would you know what method to invoke?
- andyferris 3y agoYou should look into the union keyword in C :) (Basically the programmer has to figure out how discrimination works - you’re kinda on your own).
- yxhuvud 3y agoBut eh, that is not the case in crystal. You are not on your own - the language knows what a variable is during runtime and you have plenty of ways to dispatch between the types.