--- a/package.lisp Sat Feb 02 14:29:29 2019 -0500
+++ b/package.lisp Sat Feb 23 22:30:01 2019 -0500
@@ -82,6 +82,7 @@
(:use :cl :iterate :losh.quickutils)
(:documentation "Utilities for input/output/reading/etc.")
(:export
+ :read-all
:read-all-from-file
:read-all-from-string))
--- a/src/io.lisp Sat Feb 02 14:29:29 2019 -0500
+++ b/src/io.lisp Sat Feb 23 22:30:01 2019 -0500
@@ -1,5 +1,11 @@
(in-package :losh.io)
+(defun read-all (stream)
+ "Read all forms from `stream` and return them as a fresh list."
+ (iterate
+ (for v :in-stream stream)
+ (collect v)))
+
(defun read-all-from-string (string)
"Read all forms from `string` and return them as a fresh list."
(iterate
@@ -14,10 +20,4 @@
(defun read-all-from-file (path)
"Read all forms from the file at `path` and return them as a fresh list."
(with-open-file (file path :direction :input)
- (iterate
- (with done = (gensym))
- (for form = (read file nil done))
- (while (not (eq form done)))
- (collect form))))
-
-
+ (read-all file)))