From 60069b30d40d0db5eeba71aee1c1d0a29ba702a6 Mon Sep 17 00:00:00 2001 From: Martin Gasbichler Date: Thu, 13 Feb 2003 12:05:57 +0000 Subject: [PATCH] Code from Marc Feeley's Scheme 2001 paper. --- .../continuation-data-type.scm | 18 ++++++++++++++++++ s48/continuation-data-type/interfaces.scm | 4 ++++ s48/continuation-data-type/packages.scm | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 s48/continuation-data-type/continuation-data-type.scm create mode 100644 s48/continuation-data-type/interfaces.scm create mode 100644 s48/continuation-data-type/packages.scm diff --git a/s48/continuation-data-type/continuation-data-type.scm b/s48/continuation-data-type/continuation-data-type.scm new file mode 100644 index 0000000..e483334 --- /dev/null +++ b/s48/continuation-data-type/continuation-data-type.scm @@ -0,0 +1,18 @@ + +;; Taken from Marc Feeley's paper "A Better API for First-Class Continunations" +;; The version from the workshop proceedings contains a bug in continuation-capture. +;; This is the corrected version. + +(define (continuation-capture receiver) + ((call-with-current-continuation + (lambda (cont) + (lambda () (receiver cont)))))) + +(define (continuation-graft cont thunk) + (cont thunk)) + +(define (continuation-return cont . returned-values) + (continuation-graft + cont + (lambda () (apply values returned-values)))) + diff --git a/s48/continuation-data-type/interfaces.scm b/s48/continuation-data-type/interfaces.scm new file mode 100644 index 0000000..72f14ac --- /dev/null +++ b/s48/continuation-data-type/interfaces.scm @@ -0,0 +1,4 @@ +(define-interface continuation-data-type-interface + (export continuation-capture + continuation-graft + continuation-return)) diff --git a/s48/continuation-data-type/packages.scm b/s48/continuation-data-type/packages.scm new file mode 100644 index 0000000..d6bc5a2 --- /dev/null +++ b/s48/continuation-data-type/packages.scm @@ -0,0 +1,3 @@ +(define-structure continuation-data-type continuation-data-type-interface + (open scheme) + (files continuation-data-type)) \ No newline at end of file