Skip to content

Show, showcompact, showall, showlimited, print, repr, summary, and friends #5709

@mbauman

Description

@mbauman

In creating PR #5706 I had some trouble in figuring out what all the different flavors of show do. There seems to be some consensus on what information should be displayed when pretty-printing types, often like:

TypeInformation and some metadata here:
  (with the data expressed here)

But how this happens, and, more importantly, how output is limited seems to be somewhat haphazard. In turn, it's hard for users to determine which functions should be implemented for their types — it took me a long time to realize that showcompact is orthogonal to showlimited (the former does things like shortening floating point precision while the latter omits elements, if I now understand correctly.)

I searched through the issues and while there's some smattering of discussion about specific datatypes and there are some todo notes in the code but I thought there might be some value in looking at the overall architecture. With IJulia and REPL.jl around the corner, it might be nice to standardize some of these functions. I'm sure @tknopp will have some thoughts here as he implements his workspace browser.

As I see it, there are two or three different feature sets that are important for writing to MIME"text/plain":

  • Printing with full or limited precision
  • Printing with full or limited number of rows and columns
  • Printing with or without summary information

Of course, what makes this difficult is that in the implementation, you generally only want to use one function with minor adjustments. Would the situation be improved with just one show API along the lines of the amazing showarray (albeit without keyword arguments)?

function showarray(io::IO, X::AbstractArray,
                   header::Bool=true, limit::Bool=_limit_output,
                   rows = tty_rows()-4, cols = tty_cols())

Users could choose to ignore the final arguments and multiple dispatch could be setup to ignore them if users only defined it in terms of the first two arguments. This is just a spitball to get the discussion rolling… is there interest in doing something here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    display and printingAesthetics and correctness of printed representations of objects.docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions