txt: ## temp.md
  temp
  
  Combined from primary sources listed below.
  
  # [In Operators](#___top "go to top of document")[§](#(Operators)_prefix_temp "direct link")
  
  See primary documentation
  [in context](/language/operators#prefix_temp)
  for **prefix temp**.
  
  ```raku
  sub prefix:<temp>(Mu $a is rw)
  ```
  
  "temporizes" the variable passed as the argument. The variable begins with the same value as it had in the outer scope, but can be assigned new values in this scope. Upon exiting the scope, the variable will be restored to its original value.
  
  ```raku
  my $a = "three";
  say $a; # OUTPUT: «three␤»
  {
      temp $a;
      say $a; # OUTPUT: «three␤»
      $a = "four";
      say $a; # OUTPUT: «four␤»
  }
  say $a; # OUTPUT: «three␤»
  ```
  
  You can also assign immediately as part of the call to temp:
  
  ```raku
  temp $a = "five";
  
  ```
  
  Be warned the `temp` effects get removed once the block is left. If you were to access the value from, say, within a [`Promise`](/type/Promise) after the `temp` was undone, you'd get the original value, not the `temp` one:
  
  ```raku
  my $v = "original";
  {
      temp $v = "new one";
      start {
          say "[PROMISE] Value before block is left: `$v`";
          sleep 1;
          say "[PROMISE] Block was left while we slept; value is now `$v`";
      }
      sleep ½;
      say "About to leave the block; value is `$v`";
  }
  say "Left the block; value is now `$v`";
  sleep 2;
  
  # OUTPUT:
  # [PROMISE] Value before block is left: `new one`
  # About to leave the block; value is `new one`
  # Left the block; value is now `original`
  # [PROMISE] Block was left while we slept; value is now `original`
  
  ```
  
  # [In Variables](#___top "go to top of document")[§](#(Variables)_prefix_temp "direct link")
  
  See primary documentation
  [in context](/language/variables#The_temp_prefix)
  for **The temp prefix**.
  
  Like `my`, `temp` restores the old value of a variable at the end of its scope. However, `temp` does not create a new variable.
  
  ```raku
  my $in = 0; # temp will "entangle" the global variable with the call stack
              # that keeps the calls at the bottom in order.
  sub f(*@c) {
      (temp $in)++;
       "<f>\n"
       ~ @c».indent($in).join("\n")
       ~ (+@c ?? "\n" !! "")
       ~ '</f>'
  };
  sub g(*@c) {
      (temp $in)++;
      "<g>\n"
      ~ @c».indent($in).join("\n")
      ~ (+@c ?? "\n" !! "")
      ~ "</g>"
  };
  print g(g(f(g()), g(), f()));
  
  # OUTPUT: «<g>
  #           <g>
  #            <f>
  #             <g>
  #             </g>
  #            </f>
  #            <g>
  #            </g>
  #            <f>
  #            </f>
  #           </g>
  #          </g>␤»
  ```
  