Skip to content

Commit

Permalink
Merge pull request #9100 from JuliaLang/sk/typenames
Browse files Browse the repository at this point in the history
print user-defined type names fully qualified.
  • Loading branch information
StefanKarpinski committed Nov 24, 2014
2 parents 95bb793 + 3c817f0 commit c1005a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ for p in (:Year,:Month,:Week,:Day,:Hour,:Minute,:Second,:Millisecond)
# Unless the Periods are the same type
@eval $p(x::$p) = x
# Convenience method for show()
@eval _units(x::$p) = " " * lowercase(string($p)) * (abs(value(x)) == 1 ? "" : "s")
@eval _units(x::$p) = $(" " * lowercase(string(p))) * (abs(value(x)) == 1 ? "" : "s")
# periodisless
@eval periodisless(x::$p,y::$p) = value(x) < value(y)
# AbstractString parsing (mainly for IO code)
Expand Down
11 changes: 9 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function show(io::IO, x::DataType)
if isvarargtype(x)
print(io, x.parameters[1], "...")
else
print(io, x.name.name)
show(io, x.name)
if length(x.parameters) > 0
show_comma_array(io, x.parameters, '{', '}')
end
Expand All @@ -103,7 +103,14 @@ macro show(exs...)
return blk
end

show(io::IO, tn::TypeName) = print(io, tn.name)
function show(io::IO, tn::TypeName)
if tn.module == Core || tn.module == Base || tn.module == Main
print(io, tn.name)
else
print(io, tn.module, '.', tn.name)
end
end

show(io::IO, ::Void) = print(io, "nothing")
show(io::IO, b::Bool) = print(io, b ? "true" : "false")
show(io::IO, n::Signed) = (write(io, dec(n)); nothing)
Expand Down

0 comments on commit c1005a2

Please sign in to comment.