Re:Virtual Structs Part 1: Where Rust’s Enum Shines
by vezzy-fnord on Tuesday May 05, 2015 @03:05PM
(#9494280)
ML-style pattern matching is neat. There's actually an entire formal logic of computation oriented around it called the pattern calculus, though it's still in relatively early research.
That said, the language with the most powerful pattern matching engine I've used so far has been Erlang. Just about everything there is intimately tied to it, giving it a homoiconicity between the code and the literal data types. You can even pattern match on binary formats, like file headers or packet structures.
It seems like Algol-like languages are slowly absorbing lessons from ML. Rust is quite an evident example.
Re:Virtual Structs Part 1: Where Rust’s Enum Shines
by gnuvince on Tuesday May 05, 2015 @02:38PM
(#9494130)
I needed to write a small AST in Java, and I actually had to write the definition in ML on a sheet of paper to see how to do it. It's so weird that so many languages don't have sum types.
Re:Virtual Structs Part 1: Where Rust’s Enum Shines
by sixbrx on Tuesday May 05, 2015 @02:50PM
(#9494208)
What's too bad is that Java had a chance to handle alternatives properly as sum types, when enums were being added. But the designers chose instead of sum types, to add them as yet another kind of "object" that have to have a common constructor (and thus the exact same backing data) and methods. So basically all the variants have to be of the same "shape". Very disappointing!
I don't know what the language of the future will be but I can't imagine it not having an ML heritage.