Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treatment of suffix in *print-lines* is ambiguous #43

Open
yitzchak opened this issue Mar 31, 2024 · 0 comments
Open

Treatment of suffix in *print-lines* is ambiguous #43

yitzchak opened this issue Mar 31, 2024 · 0 comments
Labels
needs writeup A problem description that should be turned into a written-up issue

Comments

@yitzchak
Copy link
Member

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 ..)]"
@scymtym scymtym added the needs writeup A problem description that should be turned into a written-up issue label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs writeup A problem description that should be turned into a written-up issue
Projects
None yet
Development

No branches or pull requests

2 participants