Constant String Hack

AMG: What is this? It's referenced on Hypnotoads Todo List.

aspect: it's a way to conserve memory when constant strings are used repeatedly in your code. Instead of each instance of the same string potentially allocating a duplicate Tcl_Obj, a pool is allocated and re-used.

Here's a script-level interpretation, logged in Dec 2014:

# hypnotoad @ comp.lang.tcl:
# My application (The Integrated Recoverability Model) also builds giant dicts.
# The only way I get around the computer eating itself alive is to re-use literals.
# I do it in C, but on the Tcl level you could implement the following:

proc literal VALUE {
  if {![info exists ::literal($VALUE)]} {
   set ::literal($VALUE) $VALUE
  return $::literal($VALUE)

# When you build your dict:
# dict set result {*}$path [literal $key] [literal $value]
# The technique allows a single Tcl_Obj* to represent every instance where the
# same literal string value is used.

An extension doing the same thing can be found in odielib . The linked C file (quoting the toad) "is self contained and well behaved, so it should drop into anything else you are doing".