From 8ffbc2df0fde83082610149d24e594c1cd879f4a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:25 -0800 Subject: Import Upstream version 2a6 --- promise.scm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 promise.scm (limited to 'promise.scm') diff --git a/promise.scm b/promise.scm new file mode 100644 index 0000000..f38aebf --- /dev/null +++ b/promise.scm @@ -0,0 +1,29 @@ +;;;"promise.scm" promise for force and delay +;;; From Revised^4 Report on the Algorithmic Language Scheme +;;; Editors: William Clinger and Jonathon Rees +; +; We intend this report to belong to the entire Scheme community, and so +; we grant permission to copy it in whole or in part without fee. In +; particular, we encourage implementors of Scheme to use this report as +; a starting point for manuals and other documentation, modifying it as +; necessary. + +(define promise:force (lambda (object) (object))) + +(define make-promise + (lambda (proc) + (let ((result-ready? #f) + (result #f)) + (lambda () + (if result-ready? + result + (let ((x (proc))) + (if result-ready? + result + (begin (set! result-ready? #t) + (set! result x) + result)))))))) + +;;; change occurences of (DELAY ) to +;;; (MAKE-PROMISE (LAMBDA () )) +;;; and (define force promise:force) -- cgit v1.2.3