home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / guile-ii.src / guile-ii / guile-src / slib / promise.scm < prev    next >
Encoding:
Text File  |  1994-07-11  |  902 b   |  30 lines

  1. ;;;"promise.scm" promise for force and delay
  2. ;;; From Revised^4 Report on the Algorithmic Language Scheme
  3. ;;; Editors: William Clinger and Jonathon Rees
  4. ;
  5. ; We intend this report to belong to the entire Scheme community, and so
  6. ; we grant permission to copy it in whole or in part without fee.  In
  7. ; particular, we encourage implementors of Scheme to use this report as
  8. ; a starting point for manuals and other documentation, modifying it as
  9. ; necessary.
  10.  
  11. (define promise:force (lambda (object) (object)))
  12.  
  13. (define make-promise
  14.   (lambda (proc)
  15.     (let ((result-ready? #f)
  16.       (result #f))
  17.       (lambda ()
  18.     (if result-ready?
  19.         result
  20.         (let ((x (proc)))
  21.           (if result-ready?
  22.           result
  23.           (begin (set! result-ready? #t)
  24.              (set! result x)
  25.              result))))))))
  26.  
  27. ;;; change occurences of (DELAY <expression>) to
  28. ;;; (MAKE-PROMISE (LAMBDA () <expression>))
  29. ;;; and (define force promise:force)
  30.