title: Scalar value being affected after push, or not... (Raku)
body: <p>I have difficulty understanding when and why the value held by a pushed <code>Scalar</code> container is affected after the push. I'll try to illustrate the issue that I ran into in a more complicated context in two stylized examples. </p>
  
  <p><strong>*Example 1 *</strong> In the first example, a scalar <code>$i</code> is pushed onto an array <code>@b</code> as part of a <code>List</code>. After the push, the value held by the scalar is explicitly updated in later iterations of the for loop using the <code>$i++</code> instruction. These updates have an effect on the value in the array <code>@b</code>: at the end of the for loop, <code>@b[0;0]</code> is equal to <code>3</code>, and no longer to <code>2</code>.</p>
  
  <pre><code>my @b;
  my $i=0;
  for 1..3 -&gt; $x {
    $i++;
    say 'Loose var $i: ', $i.VAR.WHICH, " ", $i.VAR.WHERE;
    if $x == 2 {
       @b.push(($i,1));
       say 'Pushed $i   : ', @b[0;0].VAR.WHICH, " ", @b[0;0].VAR.WHERE;
    }
  }
  say "Post for-loop";
  say "Array       : ", @b;
  say 'Pushed $i   : ', @b[0;0].VAR.WHICH, " ", @b[0;0].VAR.WHERE;
  </code></pre>
  
  <p>Output example 1: </p>
  
  <pre><code>Loose var $i: Scalar|94884317665520 139900170768608
  Loose var $i: Scalar|94884317665520 139900170768648
  Pushed $i   : Scalar|94884317665520 139900170768648
  Loose var $i: Scalar|94884317665520 139900170768688
  Post for-loop
  Array       : [(3 1)]
  Pushed $i   : Scalar|94884317665520 139900170768688
  </code></pre>
  
  <p><strong>* Example 2 *</strong> In the second example, the scalar <code>$i</code> is the loop variable. Even though <code>$i</code> is updated after it has been pushed (now implicitly rather than explicitly), the value of <code>$i</code> in array <code>@c</code> does <strong>not</strong>
  change after the push; i.e. after the for loop, it is still <code>2</code>, not <code>3</code>.</p>
  
  <pre><code>my @c;
  for 1..3 -&gt; $i {
    say 'Loose var $i: ', $i.VAR.WHICH, " ", $i.VAR.WHERE;
    if $i == 2 {
       @c.push(($i,1));
       say 'Pushed $i   : ', @c[0;0].VAR.WHICH, " ", @c[0;0].VAR.WHERE;
    }
  }
  say "Post for-loop";
  say "Array       : ", @c;
  say 'Pushed $i   : ', @c[0;0].VAR.WHICH, " ", @c[0;0].VAR.WHERE;;
  </code></pre>
  
  <p>Output example 2: </p>
  
  <pre><code>Loose var $i: Scalar|94289037186864 139683885277408
  Loose var $i: Scalar|94289037186864 139683885277448
  Pushed $i   : Scalar|94289037186864 139683885277448
  Loose var $i: Scalar|94289037186864 139683885277488
  Post for-loop
  Array       : [(2 1)]
  Pushed $i   : Scalar|94289037186864 139683885277448
  </code></pre>
  
  <p><strong>Question:</strong> Why is <code>$i</code> in <code>@b</code> in example 1 updated after the push, while <code>$i</code> in <code>@c</code> in example 2 is not?</p>
  
  <p><strong>edit</strong>:
  Following @timotimo's comment, I included the output of <code>.WHERE</code> in the examples. This shows the (WHICH/logical) scalar-identity of <code>$i</code> stays the same, while its memory address changes through the various loop iterations. But it does not explain why in example 2 the pushed scalar remains tied to the same WHICH-identity in combination with an old address ("448).</p>