forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
methodshow: single-line printing for
Method
by default (JuliaLang#4…
…6241) Currently `show(::IO, ::Method)` prints the method object in multiple-line as like: ```julia julia> only(methods(sin, (Float64,))) sin(x::T) where T<:Union{Float32, Float64} @ Base.Math special/trig.jl:29 ``` and this could be confusing when used within a container e.g.: ```julia julia> Any[only(methods(sin, (Float64,)))] 1-element Vector{Any}: sin(x::T) where T<:Union{Float32, Float64} @ Base.Math special/trig.jl:29 julia> code_lowered() do; Base.Experimental.@opaque a::Int -> sin(a); end 1-element Vector{Core.CodeInfo}: CodeInfo( 1 ─ %1 = Core.apply_type(Core.Tuple, Main.Int) │ %2 = Core.apply_type(Core.Union) │ %3 = $(Expr(:new_opaque_closure, :(%1), :(%2), :(Core.Any), opaque closure(...) @ Main none:0)) └── return %3 ) ``` This commit refactors the `show` method for `Method` object so that `show(::IO, ::Method)` prints it within a single line by default and `show(::IO, ::MIME"text/plain", ::Method)` prints within 2-lines, that I believe is more aligned with printing implementations for the other types: ```julia julia> Any[only(methods(sin, (Float64,)))] 1-element Vector{Any}: sin(x::T) where T<:Union{Float32, Float64} @ Base.Math special/trig.jl:29 julia> code_lowered() do; Base.Experimental.@opaque a::Int -> sin(a); end 1-element Vector{Core.CodeInfo}: CodeInfo( 1 ─ %1 = Core.apply_type(Core.Tuple, Main.Int) │ %2 = Core.apply_type(Core.Union) │ %3 = $(Expr(:new_opaque_closure, :(%1), :(%2), :(Core.Any), opaque closure(...) @ Main none:0)) └── return %3 ) ```
- Loading branch information
Showing
8 changed files
with
52 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters