[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: please explain prompt scope
From: |
Matt Wette |
Subject: |
Re: please explain prompt scope |
Date: |
Thu, 19 Oct 2017 18:42:52 -0700 |
> On Oct 17, 2017, at 5:38 AM, Matt Wette <address@hidden> wrote:
>
> Here is a program that uses prompt and capture the continuation in top-level
> binding.
>
> (define (sf fmt . args) (apply simple-format #t fmt args))
>
> (define At (make-prompt-tag))
>
> (define Ak #f)
>
> (let ((a 2))
> (call-with-prompt At
> (lambda ()
> (sf "hello\n")
> (abort-to-prompt At)
> (sf "world where a=~S\n" a))
> (lambda (k . args)
> (set! Ak k)
> (sf "!\n")))
> (set! a 99))
>
> (Ak)
>
> Here is the output:
> hello
> !
> world where a=99
>
> Can someone explain how `a' is captured in the continuation?
> Does the continuation include the stack outside `prompt'?
I am reading up on this now:
Sec 9.3 of the Guile 2.2 Manual
and
https://www2.ccs.neu.edu/racket/pubs/lasc1990-sf.pdf