Skip to content

Conversation

@bombless
Copy link
Contributor

@bombless bombless commented Apr 7, 2015

I think "let is used to introduce variables" is incorrent.
You can use

match (42, true) {
    (x, y) => { /* ... */ }
}

to replace

let x = 42;
let y = true;

so it's nothing special for let.

@rust-highfive
Copy link
Contributor

r? @pcwalton

(rust_highfive has picked a reviewer for you, use r? to override)

@bombless
Copy link
Contributor Author

bombless commented Apr 7, 2015

Thanks for @jorisgio reminding me that the binding of let can happen later in control flow.
So it is one reason to remain the doc as-is.

But consider this:

fn main() {
    let (x, (y,));
    x = 10;
    y = true;
}

playpen
If you say this let is introducing variables, I don't want to believe that.

I still suggest there's no "variable definition" in Rust.

@jorisgio
Copy link

jorisgio commented Apr 7, 2015

In my opinion, in let mut x = 4; x += 1;, x is a variable. As for the let x; it's just a split binding pattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a newline after this, to make a new paragraph. also, the wrapping seems a bit odd.

@steveklabnik
Copy link
Contributor

The official term is 'variable bindings', though sometimes, people just say one or the other.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to change this to "Why is let used to introduce variables?"

@steveklabnik
Copy link
Contributor

I do think this needs improvement and this is overall an improvement, just some nits :)

@bombless
Copy link
Contributor Author

bombless commented Apr 8, 2015

Thanks :)
r? @steveklabnik

@steveklabnik
Copy link
Contributor

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 8, 2015

📌 Commit c9454b1 has been approved by steveklabnik

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 8, 2015
I think "let is used to introduce variables" is incorrent.
You can use
```rust
match (42, true) {
    (x, y) => { /* ... */ }
}
```
to replace
```rust
let x = 42;
let y = true;
```
so it's nothing special for `let`.
bors added a commit that referenced this pull request Apr 8, 2015
@bors bors merged commit c9454b1 into rust-lang:master Apr 8, 2015
@bombless bombless mentioned this pull request Apr 18, 2015
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed a case here: for-in also do pattern matching.
I'll try update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants