3 ms·
No algebraic datatypes + pattern matching, yes I'm aware of libraries that implement it via metaprogramming, but that's not good enough for me.
by zinclozenge 6y ago
No algebraic datatypes + pattern matching, yes I'm aware of libraries that implement it via metaprogramming, but that's not good enough for me.
- kevin_thibedeau 6y agoTry using Rust without any macros.
- arc619 6y ago> No algebraic datatypes Not sure what you mean there, there's product types with tuples and objects, and sum types as object variants. > Pattern matching Eh, I mean it's just sugar over a case statement. let num = 5 str = case num of 1: "One!" of 2, 3, 5, 7, 11: "This is a prime" of 13..19: "A teen" else: "Unknown" # Compile error if all cases arent covered. As you say there's libraries that let you deconstruct and partially match more complex types if you need that. Being able to create things like pattern matching, async, and novel multithreading runtimes as a library in Nim shows how powerful (and useful) the metaprogramming is. Enums in Rust are more interesting, but again nothing you can't do with an object variant.