From: Mark H Weaver Date: Wed, 27 Mar 2013 01:22:11 +0000 (-0400) Subject: SRFI-45: add promise? predicate. X-Git-Url: http://git.hcoop.net/bpt/guile.git/commitdiff_plain/d291d7990d72b5cb8a18b20e524e1c8324297e92 SRFI-45: add promise? predicate. * module/srfi/srfi-45.scm (promise?): Export. * doc/ref/srfi-modules.texi (SRFI-45): Update docs. * test-suite/tests/srfi-45.test: Add test. Add FSF copyright for 2010 and 2013. Add missing year to André van Tonder's copyright notice. --- diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index c99905c7d..513bb5966 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -3845,6 +3845,13 @@ words, no program that uses the R5RS definitions of delay and force will break if those definition are replaced by the SRFI-45 definitions of delay and force. +Guile also adds @code{promise?} to the list of exports, which is not +part of the official SRFI-45. + +@deffn {Scheme Procedure} promise? obj +Return true if @var{obj} is an SRFI-45 promise, otherwise return false. +@end deffn + @deffn {Scheme Syntax} delay expression Takes an expression of arbitrary type @var{a} and returns a promise of type @code{(Promise @var{a})} which at some point in the future may be diff --git a/module/srfi/srfi-45.scm b/module/srfi/srfi-45.scm index 7b7fedd88..51947700c 100644 --- a/module/srfi/srfi-45.scm +++ b/module/srfi/srfi-45.scm @@ -1,6 +1,6 @@ ;;; srfi-45.scm -- Primitives for Expressing Iterative Lazy Algorithms -;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. +;; Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc. ;; Copyright (C) 2003 André van Tonder. All Rights Reserved. ;; Permission is hereby granted, free of charge, to any person @@ -25,8 +25,8 @@ ;;; Commentary: -;; This is the code of the reference implementation of SRFI-45, slightly -;; modified to use SRFI-9. +;; This is the code of the reference implementation of SRFI-45, modified +;; to use SRFI-9 and to add 'promise?' to the list of exports. ;; This module is documented in the Guile Reference Manual. @@ -36,8 +36,9 @@ #:export (delay lazy force - eager) - #:replace (delay force) + eager + promise?) + #:replace (delay force promise?) #:use-module (srfi srfi-9)) (cond-expand-provide (current-module) '(srfi-45)) diff --git a/test-suite/tests/srfi-45.test b/test-suite/tests/srfi-45.test index 573eea04a..e9fd029c9 100644 --- a/test-suite/tests/srfi-45.test +++ b/test-suite/tests/srfi-45.test @@ -1,6 +1,7 @@ ;;; -*- mode: scheme; coding: utf-8; -*- -;; Copyright André van Tonder. All Rights Reserved. +;; Copyright (C) 2010, 2013 Free Software Foundation, Inc. +;; Copyright (C) 2003 André van Tonder. All Rights Reserved. ;; ;; Permission is hereby granted, free of charge, to any person ;; obtaining a copy of this software and associated documentation @@ -258,3 +259,10 @@ ;; Commented out since it takes too long #; (test-equal 300000000 (force (times3 100000000))) ;==> bounded space + + +;====================================================================== +; Test promise? predicate (non-standard Guile extension) + +(pass-if "promise? predicate" + (promise? (delay 1)))