> Does it interact with the borrow checker somehow?
Nope. The borrow checker cares about the control flow graph, expression vs statement doesn't matter.
> why does Rust make the expression/statement distinction?
I am not 100% sure. If I had to guess, older Rust was much less expression oriented, and then, over time, got moreso.
But also, I think it kinda just makes sense in general for the kind of language Rust is. Like, in Ruby, where everything truly is an expression, importing a file and then evaluating it has side effects. Whereas in Rust, 95% of statements are declarations, and of those 95%, the only ones you really use in a normal execution context are let statements. The rest are stuff like "declaring functions" and "declaring structs" and those don't really get evaluated in a language like Rust.
let being a statement is nice because it means it can only happen at the "top level" of a block, and not say, inside a loop condition.
> Like, in Ruby, where everything truly is an expression, importing a file and then evaluating it has side effects.
In the context of ML, I think it's a more useful baseline. So declarations are still declarations, but e.g. ; is just a sequential evaluation operator.
> let being a statement is nice because it means it can only happen at the "top level" of a block, and not say, inside a loop condition.
I would argue that it's actually a downside - it means that a loop condition cannot have common subexpressions (that nevertheless need to be evaluated on every iteration) factored out.
Nope. The borrow checker cares about the control flow graph, expression vs statement doesn't matter.
> why does Rust make the expression/statement distinction?
I am not 100% sure. If I had to guess, older Rust was much less expression oriented, and then, over time, got moreso.
But also, I think it kinda just makes sense in general for the kind of language Rust is. Like, in Ruby, where everything truly is an expression, importing a file and then evaluating it has side effects. Whereas in Rust, 95% of statements are declarations, and of those 95%, the only ones you really use in a normal execution context are let statements. The rest are stuff like "declaring functions" and "declaring structs" and those don't really get evaluated in a language like Rust.
let being a statement is nice because it means it can only happen at the "top level" of a block, and not say, inside a loop condition.