returning.ss
#lang scheme/base

(require (prefix-in log: (planet synx/log:1)))

(define returner (make-parameter (λ args 
                                   (log:warning "Exiting via return (probably a bad idea!) ~s" args)
                                   (exit))))

(define (return . args)
  (apply (returner) args))

(define (returning-from thunk)
  (let/ec new-returner
    (parameterize
        ((returner new-returner))
      (thunk))))

(provide return returning-from)