From df5652f68fc0ca6730b3f830e805cf7e30e5615d Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Fri, 16 Sep 2016 00:14:28 +0200 Subject: [PATCH] Add a comment to last change in stream.el and bump version --- packages/stream/stream.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/stream/stream.el b/packages/stream/stream.el index 9954fc8..db00b0d 100644 --- a/packages/stream/stream.el +++ b/packages/stream/stream.el @@ -4,7 +4,7 @@ ;; Author: Nicolas Petton ;; Keywords: stream, laziness, sequences -;; Version: 2.2.1 +;; Version: 2.2.2 ;; Package-Requires: ((emacs "25")) ;; Package: stream @@ -237,11 +237,24 @@ START on. Both START and END must be non-negative. Since streams are a delayed type of sequences, don't signal an error if START or END are larger than the number of elements (the returned stream will simply be accordingly shorter, or even empty)." - (when (or (< start 0) (and end (< end 0))) - (error "seq-subseq: only non-negative indexes allowed for streams")) - (let ((stream-from-start (seq-drop stream start))) - (if end (seq-take stream-from-start (- end start)) - stream-from-start))) + (if (or (< start 0) (and end (< end 0))) + ;; We could return something like this (for START and END < 0): + ;; + ;; (let ((cropped stream)) + ;; (cl-dotimes (_ (- start)) (stream-pop cropped)) + ;; (while (not (stream-empty-p cropped)) + ;; (stream-pop stream) + ;; (stream-pop cropped)) + ;; (seq-take stream (- end start))) + ;; + ;; but we are not sure whether advertising negative indexes is a good + ;; idea: this would potentially create a bunch of thrown away objects, + ;; and "searching from the end" might be better in most use cases. So + ;; we raise an error instead: + (error "seq-subseq: only non-negative indexes allowed for streams") + (let ((stream-from-start (seq-drop stream start))) + (if end (seq-take stream-from-start (- end start)) + stream-from-start)))) (cl-defmethod seq-into-sequence ((stream stream)) "Convert STREAM into a sequence." -- 2.9.3