[plt-scheme] expansion continuations and barriers

From: David Van Horn (dvanhorn at cs.brandeis.edu)
Date: Tue Jul 24 14:14:03 EDT 2007

If I capture a continuation at expansion time and (later on during 
expansion) try to invoke it, I get a continuation barrier error.  Why is 
this disallowed?

Concretely:

(module syntax-cc mzscheme
   (provide (all-defined))
   (require-for-syntax (lib "boundmap.ss" "syntax"))

   (define-for-syntax m (make-module-identifier-mapping))

   (define-syntax syntax-let/cc
     (lambda (stx)
       (syntax-case stx ()
         ((_ x e)
          (let/cc k
            (module-identifier-mapping-put! m (syntax x) k)
            (syntax e))))))

   (define-syntax syntax-invoke/c
     (lambda (stx)
       (syntax-case stx ()
         ((_ x e)
          ((module-identifier-mapping-get m (syntax x))
           (syntax e))))))
   )

(require syntax-cc)
(syntax-let/cc k
   (begin
     (syntax-invoke/c k #t)
     (let)))

;; ==expand==> #t, (let) is not expanded, so no compile time error.



Posted on the users mailing list.