3 ms·
> Structs/enums are also basically Scala. How so? Scala class bodies are a mix of ordered constructor statements and unordered declarations/method definitions,
by johncolanduoni 10y ago
> Structs/enums are also basically Scala.
How so? Scala class bodies are a mix of ordered constructor statements and unordered declarations/method definitions, while Rust structs can only declare fields (without any sort of initial value). Scala enumerations (both scala.Enumeration and the more common sealed class versions) look nothing like a Rust enum; if anything Rust enums look like ML/Haskell algebraic type definitions.
> It's true, Scala syntax for types is the weirdest part, but once you know what it means it's not hard to decipher.
The part of the type syntax that is like Scala (i.e. the colons and arrows) has its origins in the ML family IIRC. Rust's bootstrapping compiler was written in OCaml, so I suspect that was in fact the inspiration.
- cormacrelf 10y agoAh, I see it's been a while since I've used Scala. I think I should have referred to case classes. Weak point nonetheless. I did fail to mention the other very Scala thing: match expressions. Most complicated Rust match expressions could almost compile without errors in Scala.