I've seen mentioned in a few texts that Tcl uses reference counting for garbage collection. I was wondering what this means, since as far as I can tell Tcl doesn't have pointers or references, so every variable is only referenced once. What exactly is it counting, then?
The idea is that Tcl has reference counting on values, not variables.
Let's cite the wiki page on copy-on-write semantics:
The only thing missing in this explanation is that when the refcount of a value drops belov 1, the value is destroyed.
For hard-core information, read the "Storage Management of Objects" section of the
Tcl_Objmanual page and these discussions.