3 ms·
I think the author was indicating that while you can use that syntax to declare and initialize variables, you can't use it later to assign new values to them. I
by losvedir 11y ago
I think the author was indicating that while you can use that syntax to declare and initialize variables, you can't use it later to assign new values to them. I don't think they had any problems with the concept of `let`.
And it does strike me as a little weird as well to only be able to take advantage of the pattern match destructuring on initialization, but I'm sure there's a good technical reason.
- deng 11y agoI read it the same way. There's an open issue for it: https://github.com/rust-lang/rfcs/issues/372 https://github.com/rust-lang/rfcs/issues/372 I think one of the main reasons this isn't done is because of the grammar issue. I dimly remember that one of the goals of Rust was to be parseable with a LL(1) grammar.
- steveklabnik 11y agoThere are grammar issues, yes. We unfortunately have one tiny case that's context-sensitive though, so we didn't quite get there :/ that vast majority of the grammar is very straightforward though. There's a lot of benefit to it.
- masklinn 11y agoThe main reason this isn't done is that `let (a, b) = (…)` is the pattern matching of two tuples, but assignment doesn't do pattern-matching.