[gambit-list] Android Gambit Error

Steve Graham jsgrahamus at yahoo.com
Wed Sep 14 23:02:33 EDT 2011


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.

Gambit v4.6.1

>  (define (counter)
        (let ((value 0))
              (lambda ()
                  (set! value (+ value 1))
                  value)))

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.

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.

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:

Gambit v4.6.1

> (define (counter)
        (let ((value 0))
              (lambda ()
                  (set! value (+ value 1))
                  value)))
> (define first-counter (counter))
> (first-counter)
1
> (first-counter)
2
> (first-counter)
3
> (first-counter)
4
>

 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.

TIA, Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20110914/41224e74/attachment.htm>


More information about the Gambit-list mailing list