# HG changeset patch # User Steve Losh # Date 1621832742 14400 # Node ID 6740e201e636ae6d14736a58b9ed5c72332b58a8 # Parent 91ea751ccd9f1b6ace12946efb7a434b22b3adbb Fix concatenating to handle separators properly diff -r 91ea751ccd9f -r 6740e201e636 src/iterate.lisp --- a/src/iterate.lisp Mon May 24 01:05:13 2021 -0400 +++ b/src/iterate.lisp Mon May 24 01:05:42 2021 -0400 @@ -675,7 +675,8 @@ a fresh string each time or whether an adjustable string is mutated is implementation defined. - If `separator` is not `nil`, it must be a string designator. + If `separator` is not `nil` it must be a string designator, and it will be + evaluated once at the beginning of the iterate form. Examples: @@ -718,11 +719,12 @@ (let ((sos (gensym "SOS")) (sep (gensym "SEP"))) `(progn - (with ,sos = (make-string-output-stream)) + (with ,sos = nil) (with ,sep = ,(if separator (string separator) nil)) - (if-first-time - nil - (when ,sep (write-string ,sep ,sos))) + (if (null ,sos) + (setf ,sos (make-string-output-stream)) + (when ,sep + (write-string ,sep ,sos))) (write-string ,expr ,sos) (finally (return (get-output-stream-string ,sos)))))))