[Pitch] Last expression as return value

I’m mostly going to stay out of this one, but I’ll note that my reason for disliking this in Rust is that both { foo(); bar() } and { foo(); bar(); } are valid but mean different things. This still isn’t much of a problem in practice because the two forms have different result types (or they don’t and it doesn’t matter), and therefore they usually will result in a compiler error if you get it wrong. But it’s still annoying to me.

Swift won’t have that problem because the two forms will be equivalent, though I also expect linters to complain about a final semicolon if the value is used or returned. Swift also warns on unused values by default, which Rust does not, so if you meant to supply a result and somehow screw it up you’re more likely to be told.

35 Likes