3 ms·
> Some constructs are more natural (e.g. easier to read and write) as statements, others as expressions. Yes but imo, Haskell (which has do notation) and Rust
by creata 6y ago
> Some constructs are more natural (e.g. easier to read and write) as statements, others as expressions.
Yes but imo, Haskell (which has do notation) and Rust (where most things are expressions, but you still write them as expression statements when writing imperative code) actually have solutions to this problem. On the other hand, Python has a sharp divide between expressions and statements, so it needs strange duplicate forms of statements as expressions, like ternaries (if expressions but in a really weird order!) and lambdas (function expressions but your body is just an expression!)
> So when someone like Guido says, "it will complicate things"
Yes, it would complicate Python, which already has this division. In other languages, it's perfectly simple.
- pansa2 6y agoIn Rust, some expressions (e.g. `while`) always evaluate to `()`. What’s the benefit of that compared to making `while` a statement?
- deleted 6y ago[deleted]
- creata 6y agoI can't think of a benefit (besides consistency, which might be nice for some macros) but is it doing any harm? And, in the future, if Rust does get some kind of return-via-break for while loops (like it has for `loop`s) then there'll be less syntax to change.