wscl
wscl copied to clipboard
Treatment of suffix in `*print-lines*` is ambiguous
In the descriptions of *print-lines*
it states:
If an attempt is made to go beyond that many lines, “..” is printed at the end of the last line followed by all of the suffixes (closing delimiters) that are pending to be printed.
This is a bit ambiguous in the case that the suffix contains newlines. In that case should the suffix be printed with the containing newlines or should only the suffix text that trails the newlines be printed? Most implementations seem to assume the former, but this causes the number of lines to exceed *print-lines*
. For example, on SBCL:
* (with-output-to-string (stream)
(let ((*print-pretty* t)
(*print-lines* 1))
(pprint-logical-block (stream nil :prefix "[" :suffix "a
]")
(pprint-logical-block (stream nil :prefix "(" :suffix ")")
(write-string "wibble" stream)
(pprint-newline :mandatory stream)
(write-string "bar" stream)))))
"[(wibble ..)a
]"
An alternative would be to do as Inravina does currently:
* (with-output-to-string (stream)
(let ((*print-pretty* t)
(*print-lines* 1))
(inravina-extrinsic:pprint-logical-block (stream nil :prefix "[" :suffix "a
]")
(inravina-extrinsic:pprint-logical-block (stream nil :prefix "(" :suffix ")")
(write-string "wibble" stream)
(inravina-extrinsic:pprint-newline :mandatory stream)
(write-string "bar" stream)))))
"[(wibble ..)]"