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

New prettyprinter puts line breaks in undesirable places #1275

Closed
brianhuffman opened this issue Sep 2, 2021 · 0 comments · Fixed by #1276
Closed

New prettyprinter puts line breaks in undesirable places #1275

brianhuffman opened this issue Sep 2, 2021 · 0 comments · Fixed by #1276

Comments

@brianhuffman
Copy link
Contributor

The commit message in 35bb83b, which switched cryptol to use the more modern prettyprinter library, mentions this explicitly as a drawback:

The one somewhat negative outcome of this change is that the "line fill" algorithm in prettyprinter works a bit different and makes choices about where to break lines that are arguably less desirable than before. When laying out structures nested inside sequences, it is more likely to break a line inside a substructure, whereas the old algorithm prefered to break lines between elements of the outer sequence.

Here's an example that shows line breaks that fall inside inner tuples:

[(0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00,
  0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01),
 (0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00,
  0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01)]

In cryptol-2.11 the same expression was printed much more nicely:

[(0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01),
 (0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01),
 (0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01),
 (0x00, 0x01), (0x00, 0x01), (0x00, 0x01), (0x00, 0x01),
 (0x00, 0x01)]

The new output is harder to read. We should change it to produce output like before.

brianhuffman pushed a commit that referenced this issue Sep 3, 2021
The combinator is altered so that if a list item cannot be laid
out on a single line, then we insert a linebreak before it so that
it starts on its own line.

Fixes #1275.
@brianhuffman brianhuffman linked a pull request Sep 3, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant