title: Do any languages let you remove a variable from scope?
body: <p>There's an occasional source of bugs in my Scala code, when I do a number of operations in order to a variable, creating lots of intermediate variables.</p>
  
  <pre><code>class SomeClass(name: String) {
  
    def doSomeThings() {
      val canonicalizedName = canonicalizeName(name)
      val boozbangledName = boozbangle(canonicalizedName)
      val plobberedName = plobber(boozbangledName)
      val flemmedName = flem(boozbangledName) // bug!  should have been flem(plobberedName)
      // (more code)
      doAThing(flemmedName) // correct!
      doAnotherThing(name)     // bug!  should have been doAnotherThing(flemmedName)
    }
  }
  </code></pre>
  
  <p>Is there any way to prevent this sort of bug, in any programming language - e.g. remove "deprecated" variables from scope?  I could use a <code>var</code> to prevent the first bug, but it still doesn't prevent the second:</p>
  
  <pre><code>class SomeClass(name: String) {
  
    def doSomeThings() {
      var fixedName = name
      fixedName = canonicalizeName(fixedName)
      fixedName = boozbangle(fixedName)
      fixedName = plobber(fixedName)
      fixedName = flem(fixedName)
      // (more code)
      doAThing(fixedName) // good!
      doAnotherThing(name)     // bug!  should have been doAnotherThing(flemmedName)
    }
  }
  </code></pre>
  
  <p>}</p>