guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

please explain prompt scope


From: Matt Wette
Subject: please explain prompt scope
Date: Tue, 17 Oct 2017 05:38:42 -0700

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'?

Thanks much.
Matt




reply via email to

[Prev in Thread] Current Thread [Next in Thread]