From 5a2e1660c69146dfcd1fd12adcf0b552b8e60f5a Mon Sep 17 00:00:00 2001 From: Connor Horman Date: Mon, 23 Sep 2024 13:05:37 -0400 Subject: [PATCH] Add identifiers to variables.md --- src/variables.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/variables.md b/src/variables.md index 5e5ec1bc1..0e22af6a5 100644 --- a/src/variables.md +++ b/src/variables.md @@ -1,20 +1,27 @@ # Variables +r[variable] + +r[variable.intro] A _variable_ is a component of a stack frame, either a named function parameter, an anonymous [temporary](expressions.md#temporaries), or a named local variable. +r[variable.local] A _local variable_ (or *stack-local* allocation) holds a value directly, allocated within the stack's memory. The value is a part of the stack frame. +r[variable.local-mut] Local variables are immutable unless declared otherwise. For example: `let mut x = ...`. +r[variable.param-mut] Function parameters are immutable unless declared with `mut`. The `mut` keyword applies only to the following parameter. For example: `|mut x, y|` and `fn f(mut x: Box, y: Box)` declare one mutable variable `x` and one immutable variable `y`. +r[variable.init] Local variables are not initialized when allocated. Instead, the entire frame worth of local variables are allocated, on frame-entry, in an uninitialized state. Subsequent statements within a function may or may not initialize the