Skip to content

Conversation

@stevengj
Copy link
Member

@stevengj stevengj commented Aug 13, 2024

The docs say that :compact=>true in the IOContext means that the output should not contain line breaks. Clarify that this is for the 2-argument show(io, x) output.

(As opposed to 3-arg show, whose whole purpose has always been to enable verbose multi-line display, and which is normally only called at the top level by display, not for nested objects).

See also this discourse thread.

@stevengj stevengj added docs This change adds or pertains to documentation display and printing Aesthetics and correctness of printed representations of objects. labels Aug 13, 2024
- `:compact`: Boolean specifying that values should be printed more compactly, e.g.
that numbers should be printed with fewer digits. This is set when printing array
elements. `:compact` output should not contain line breaks.
elements. `:compact` output for 2-argument [`show(io, x)`](@ref) should not contain line breaks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elements. `:compact` output for 2-argument [`show(io, x)`](@ref) should not contain line breaks.
elements. `:compact` output should not contain line breaks.
This flag may be ignored for 3-argument [`show(io, mime, x)`](@ref).

I guess that this is what show for arrays and dictionaries does at present (apart from passing :compact on to the elements). It would also keep readers from asking themselves what "compact output with line breaks" may look like.

As expressed in the referenced Discourse thread, I would personally find a compact (human-readable) 3-argument show version quite useful. For this reason I suggest to add

Nevertheless, users are encouraged to take the `:compact` flag into account
when writing 3-argument `show` methods for the `"text/plain"` MIME type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display and printing Aesthetics and correctness of printed representations of objects. docs This change adds or pertains to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants