emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 7d70c0a: * packages/stream/stream.el: Update stream.el to


From: Nicolas Petton
Subject: [elpa] master 7d70c0a: * packages/stream/stream.el: Update stream.el to version 2.0.1.
Date: Mon, 26 Oct 2015 21:38:38 +0000

branch: master
commit 7d70c0a3bc50c2c25ace88d9f8d36b1b7e8a1486
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>

    * packages/stream/stream.el: Update stream.el to version 2.0.1.
---
 packages/stream/stream.el |   29 +++++++----------------------
 1 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/packages/stream/stream.el b/packages/stream/stream.el
index 5506f78..17ef877 100644
--- a/packages/stream/stream.el
+++ b/packages/stream/stream.el
@@ -4,7 +4,7 @@
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Keywords: stream, laziness, sequences
-;; Version: 2.0.0
+;; Version: 2.0.1
 ;; Package-Requires: ((emacs "25"))
 ;; Package: stream
 
@@ -54,33 +54,18 @@
 
 (eval-when-compile (require 'cl-lib))
 (require 'seq)
+(require 'thunk)
 
 (eval-and-compile
   (defconst stream--identifier '--stream--
     "Symbol internally used to identify streams."))
 
-(defmacro stream--delay (&rest body)
-  "Delay the evaluation of BODY."
-  (declare (debug t))
-  (let ((forced (make-symbol "forced"))
-        (val (make-symbol "val")))
-    `(let (,forced ,val)
-       (lambda ()
-         (unless ,forced
-           (setf ,val (progn ,@body))
-           (setf ,forced t))
-         ,val))))
-
-(defun stream--force (delayed)
-  "Force the evaluation of DELAYED."
-  (funcall delayed))
-
 (defmacro stream-make (&rest body)
   "Return a stream built from BODY.
 BODY must return nil or a cons cell, which cdr is itself a
 stream."
   (declare (debug t))
-  `(list ',stream--identifier (stream--delay ,@body)))
+  `(list ',stream--identifier (thunk-delay ,@body)))
 
 (defmacro stream-cons (first rest)
   "Return a stream built from the cons of FIRST and REST.
@@ -149,19 +134,19 @@ range is infinite."
 
 (defun stream-empty ()
   "Return an empty stream."
-  (list stream--identifier (stream--delay nil)))
+  (list stream--identifier (thunk-delay nil)))
 
 (defun stream-empty-p (stream)
   "Return non-nil is STREAM is empty, nil otherwise."
-  (null (stream--force (cadr stream))))
+  (null (thunk-force (cadr stream))))
 
 (defun stream-first (stream)
   "Return the first element of STREAM."
-  (car (stream--force (cadr stream))))
+  (car (thunk-force (cadr stream))))
 
 (defun stream-rest (stream)
   "Return a stream of all but the first element of STREAM."
-  (or (cdr (stream--force (cadr stream)))
+  (or (cdr (thunk-force (cadr stream)))
       (stream-empty)))
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]