title: Linked Lists in Lua
body: <p>I've recently been looking up linked lists in Lua and have a quick question that so far I haven't been able to find an answer for </p>
  
  <pre><code>local head = nil
  
  head = {next = head, value = "d"}
  head = {next = head, value = "c"}
  head = {next = head, value = "b"}
  head = {next = head, value = "a"}
  
  local entry = head
  
  while entry do
    print(entry.value)
  
    entry = entry.next
  end
  </code></pre>
  
  <p>This will end up printing out "a,b,c,d". I understand why it would print out backwards, as the first 'node' available would be the final one created (with value = a). My question is why the 'head's created before the final one still exist and have not simply been overwritten in the memory. </p>