You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found myself using this 3-liner over and over again:
(defunread-from-stream (stream)
"Return a list of all s-expressions read in STREAM."
(loop:for value := (readstreamnilstream)
:until (eq value stream)
:collect value))
Considering the standard already has read-from-string, it's only logical to have the STREAM counterpart. With the small difference that it loops over all s-exps and returns the list of them.
Wanna add it to Serapeum?
The text was updated successfully, but these errors were encountered:
Actually I realized that uiop has uiop:slurp-stream-forms and uiop:safe-read-from-string.
So here are the missing parts:
(defunsafe-read (&optional
(input-stream *standard-input*)
(eof-error-p t)
(eof-value nil)
(recursive-p nil))
"Like `read' with standard IO syntax but does not accept reader macros ('#.').UIOP has `uiop:safe-read-from-string' but no `read' equivalent.This is useful if you do not trust the input."
(let ((package*package*))
(uiop:with-safe-io-syntax (:packagepackage)
(read input-stream eof-error-p eof-value recursive-p))))
(defunsafe-slurp-stream-forms (stream)
"Like `uiop:slurp-stream-forms' but wrapped in `uiop:with-safe-io-syntax' andpackage set to current package."
(uiop:with-safe-io-syntax (:package*package*)
(uiop:slurp-stream-forms stream)))
But maybe it'd be better to add it to UIOP directly?
I found myself using this 3-liner over and over again:
Considering the standard already has
read-from-string
, it's only logical to have the STREAM counterpart. With the small difference that it loops over all s-exps and returns the list of them.Wanna add it to Serapeum?
The text was updated successfully, but these errors were encountered: