title: call cc example racket
body: <p>I'm analyzing this code regarding the use of <code>call/cc</code>. This function is kind of mystical, and it's quite complicated to fully understand.</p>
  <p>I really cannot understand how this code is working. Below is my interpretation.</p>
  <pre><code>(define (print+sub x y)
    (display x)
    (display &quot; &quot;)
    (display y)
    (display &quot; -&gt; &quot;)
    (- x y))
  
  (define (puzzle)
    (call/cc (lambda (exit)
               (define (local e)
                 (call/cc
                  (lambda (local-exit)
                    (exit (print+sub e
                             (call/cc
                              (lambda (new-exit)
                                (set! exit new-exit)
                                (local-exit #f))))))))
               (local 6)
               (exit 2))))
  
  (define x (puzzle))
  </code></pre>
  <p><code>call/cc</code> is called through</p>
  <pre><code>    call/cc (lambda(exit))
  </code></pre>
  <p>and then again through</p>
  <pre><code>              (call/cc
                  (lambda (local-exit)
  </code></pre>
  <p>The function <code>local</code> is called with parameter <code>6</code> which is passed to <code>print+sub</code> as <code>x</code>. But how does the value <code>2</code> arrives to <code>print+sub</code> as <code>y</code>?</p>
  <p>And the most important part, what is the order in which all these instructions are performed?</p>