title: I get an unbound variable error when I load this function from a file with mit-scheme
body: <p>I'm learning scheme as part of a university course.</p>
  
  <p>I tried saving this code to the file fact-iter-001.scm:</p>
  
  <pre><code>(def (fact n)
    (def (fact-iter result counter)
      (if (&gt; counter n)
          result
          (fact-iter (* result counter) (+ counter 1))))
    (fact-iter 1 1))
  </code></pre>
  
  <p>When I try loading it into scheme, I gen an unbound variable error for fact-iter:</p>
  
  <p><a href="https://i.stack.imgur.com/hEgdC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hEgdC.png" alt="unbound variable: fact-iter"></a></p>
  
  <p>From my understanding of the code, "fact-iter" is defined locally inside the "fact" procedure, therefore it should be available when it is called just after being defined. Before writing this question, I also checked the book "Structure and interpretation of computer programs", where there is an almost identical example.</p>
  
  <p>I'm assuming that either my understanding of the code is totally wrong, or I'm loading the file in the wrong way, but I can't understand which and why. Can anyone help?</p>