-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
display and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.
Description
Definitions like
Line 742 in 1e76111
show(io::IO, r::OneTo) = print(io, "Base.OneTo(", r.stop, ")") |
show(io::IO, r::OneTo) = show_default(io, r; type_parameters=false)
There are many places where that's a default behavior that is wanted. For example, when all the type parameters correspond to fields that when show
'd reveal their type. For example
struct Foo{T}
x::T
end
show(Foo(Base.OneTo(3)))
produces
Foo{Base.OneTo{Int64}}(Base.OneTo(3))
,
which is unnecessary.
Also, show_default
has great logic to use IOContext
to see which names need to be qualified or not:
julia> Base.show_default(stdout, Base.OneTo(3))
Base.OneTo{Int64}(3)
julia> Base.show_default(stdout, Foo(Base.OneTo(3)))
Foo{Base.OneTo{Int64}}(Base.OneTo(3))
julia> using Base: OneTo
julia> Base.show_default(stdout, Base.OneTo(3))
OneTo{Int64}(3)
julia> Base.show_default(stdout, Foo(Base.OneTo(3)))
Foo{OneTo{Int64}}(Base.OneTo(3))
Notice the inconsistency in Foo{OneTo{Int64}}(Base.OneTo(3))
.
x-ref: #33260
JeffBezanson, nickrobinson251 and bramtayl
Metadata
Metadata
Assignees
Labels
display and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.