<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:12pt"><div style="font-size: 12pt; ">I've been studying "A Tour of Scheme in Gambit" and using Android Gambit (AG) to go through some of the exercises.  I came across the following interesting lesson and decided to try it.  And after I entered it into AG, the system did not come back from the repl.</div><div style="font-size: 12pt; "><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; "><br></span></div><div style="font-size: 12pt; "><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">Gambit v4.6.1</span><br></div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; "><div style="font-family: 'times new roman', 'new york', times, serif; "><div id="yiv1831487320">
<div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">>  (define (counter)<br>
        (let ((value 0))<br>
              (lambda ()<br>
                  (set! value (+ value 1))<br>
                  value)))</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">I tried sending it via the Share functionality to a different e-mail address than my Google address and it did not deliver it, although I could see it in the Gmail Sent folder.  I then tried sending it to the Gmail address and that did work fine.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">I noticed each time after sharing and then returning to the repl, there was a new prompt; however, I could not get the system to respond.  The only thing that worked was killing the AG task and restarting
 AG.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">On a final note, I am mystified as to how the code works.  This is an example of it being defined and run on my Windows 7x64 machine:</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div><div>Gambit v4.6.1</div><div><br></div><div>> (define (counter)</div><div>        (let ((value 0))</div><div>              (lambda ()</div><div>                  (set! value (+ value 1))</div><div>                  value)))</div><div>> (define first-counter (counter))</div><div>> (first-counter)</div><div>1</div><div>> (first-counter)</div><div>2</div><div>>
 (first-counter)</div><div>3</div><div>> (first-counter)</div><div>4</div><div>></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> It seems to initialize value to 0 and I assume that happens the first time you use (counter) to define another form.  What I don't understand is why the code for initializing is skipped every time (first-counter) is run.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">TIA, Steve<br><br><br><br><br></div>
</div><br><br></div></div></div></body></html>