Skip to content

Named Local Variable vs Local Variable #1832

Open
@kordyte

Description

@kordyte

In the introduction to variables (https://doc.rust-lang.org/nightly/reference/variables.html#r-variable.intro) 'named local variables' are introduced. From that point on the text only refers to 'local variables'. I am left with some doubt whether they are referring to the same thing. I only found the phrase 'named local variables' once. Of course, a named local variable is a local variable, but are there unnamed local variables? They would need to be different to anonymous temporaries which are explicitly listed in the first paragraph.

If my understanding is correct, I think it would be clearer if the first paragraph did not use the word 'named' and just called them 'local variable' (and 'function parameter' now I am looking at it). You could then follow it up with a statement such as 'All local variables are provided names through a let statement', and something similar for function parameters.

It feels that there is also room to explicitly state what happens with something like let _ = ...... Does this introduce a variable? I don't know the definitive answer there, but the wildcard pattern says that it does not copy, move, or borrow. So if a variable was introduced it would remain in an uninitialized state despite having an initializer. So I think that this cannot be a variable and eliminates my front-runner for what an unnamed variable looked like!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language CleanupImprovements to existing language which is correct but not clear, or missing examples, or the like.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions