5 ms·
I have the same problem with almost all new languages including Rust: everything should be an expression and not a statement. Even conditional logic constructs
by agentgt 10y ago
I have the same problem with almost all new languages including Rust: everything should be an expression and not a statement.
Even conditional logic constructs (if/else) should be an expression (i.e. return a value).
The language doesn't even have to be pure or hard core FP to follow this philosophy.
- nathancahill 10y agoI highly agree, especially about the if/else. The more I code, the more I try to elimante branching. If statements as expressions would be ideal.
- qznc 10y agoMost mainstream languages (C, Java, etc) have this. The ternary operator ?:
- 35bge57dtjku 10y agoThat's like farting in the bathtub and calling it a hot tub.
- tigershark 10y agoWhy? It is an expression, not a statement regardless of your farting nonsense.
- 35bge57dtjku 10y agoBecause they aren't the same thing.
- hermanradtke 10y agoBased on my understanding, Rust is an expressive language. What have you seen that is not expressive?
- captainmuon 10y agoActually, in Nim almost everything is an expression, including if blocks, case, and even except blocks. Together with immutable "variables" (let) this encourages a pretty functional style. I'd just wish their support for lambdas and list comprehensions would be a bit better.
- jeremyjh 10y agoYou are mistaken about rust. I can't think of a construct that is not an expression.
- steveklabnik 10y agolet x = 5; (That said, very nearly everything is an expression, yes)
- wisam 10y agoI don't know about Rust; but in ML family, everything in top level is a binding. Whether it's a variable, function, type or structure. SML is explicit about it and its syntax makes it clear what type of binding is going on. val x = 5 fun f = fn x => x * x datatype weekend = Sat | Sun So while on top level not everything is an expression, everything on the RHS is an expression.
- qwertyuiop924 10y agoIn rust, assignment isn't an expression, but everything else is.