title: decent way of nested definition in scheme
body: <p>I want to define a constant <code>foo</code> using an auxiliary function, say, <code>bar</code>. And I want to hide <code>bar</code> inside the definition of <code>foo</code>, so I come with this code:</p>
  
  <pre><code>(define foo
    (define (bar n)
      (+ n n))
    (bar 1))
  </code></pre>
  
  <p>However, this definition causes syntax errors in many scheme implementations(mit-scheme, racket, guile, etc.).</p>
  
  <p>I have three workarounds but none of them seems satisfactory:</p>
  
  <pre><code>(define foo1
    ((lambda ()
       (define (bar n)
         (+ n n))
       (bar 1))))
  
  (define foo2
    (let ((bar (lambda (n) (+ n n))))
      (bar 1)))
  
  (define (foo3)
    (define (bar n)
      (+ n n))
    (bar 1))
  </code></pre>
  
  <p><code>foo1</code> uses lambda to create an environment of writing auxiliary definitions and the parentheses seem somehow confusing.</p>
  
  <p><code>foo2</code> uses let expression but I can no longer use the syntactic sugar <code>(define (f n) ...)</code> => <code>(define f (lambda (n) ...))</code></p>
  
  <p><code>foo3</code> requires less modification comparing with the original one, but every time I want this value, I have to call <code>(foo3)</code> and do the computation all over again.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>I think this kind of nested definition makes sense, but why it is considered a syntax error?</li>
  <li>is there any decent way to write the definition of <code>foo</code>?</li>
  </ol>