5 ms·
Still, we want more things to be boldly and shamelessly borrowed from ML and Haskell * Universal pattern-matching (everywhere) * Obvious syntactic sugar fo
by throwaway487550 8y ago
Still, we want more things to be boldly and shamelessly borrowed from ML and Haskell
* Universal pattern-matching (everywhere)
* Obvious syntactic sugar for defining and applying curried
functions, partial application.
* Type-classes (as a one single major innovation in PL
since Smalltalk)
* receive (or select) with pattern matching (Erlang, protobuf).
* first class typed channels (Go).
* multimethods (CLOS).
Thank you!
- foota 8y agoWhat do protobufs have to do with select?
- throwaway487550 8y agoProtobuf does implicitly, via code-generation, what could be done explicitly via defining algebraic types and pattern-marching on receive, a-la Erlang.
- paavohtl 8y ago> Universal pattern-matching Where are you missing pattern matching? The only place I can think of where it can't be used currently is the function signature. Might be hard to retrofit to the current syntax. > Type-classes Rust's traits are type-classes. > first class typed channels Why do they need to be first class? Unlike Go, Rust's type system is powerful enough that type-safe channels can be (and have been) implemented as a library. See crossbeam-channel.
- steveklabnik 8y agoYou can use pattern matches in function signatures.
- throwaway487550 8y agoHow could I write this in Rust? fun map f [] = [] | map f (x::xs) = (f x) :: map f xs; And boy, no TCO. What a shame.
- steveklabnik 8y agoYou can only use irrefutable patterns. You’d write this by writing a match in the body. There’s been talk of maybe supporting this directy but it’s so niche there’s not a ton of demand. There is TCO, just not guaranteed. We’d like it; we have even reserved a keyword. Needs an RFC though.
- throwaway487550 8y ago> Rust's traits are type-classes. And the functor typeclass in Rust looks like...?
- paavohtl 8y agoRust doesn't currently have higher-kinded types, which are a separate feature from typeclasses. Implementing a true Functor trait is impossible without HKT, though the lack of it and other FP abstractions generally speaking hasn't been an issue.