If the underlying source is a trusted link, base/version.jl has only print() and show specific (and show is print dependent)
function print(io::IO, v::VersionNumber) print(io, v.major) print(io, '.') print(io, v.minor) print(io, '.') print(io, v.patch) if !isempty(v.prerelease) print(io, '-') print_joined(io, v.prerelease,'.') end if !isempty(v.build) print(io, '+') print_joined(io, v.build,'.') end end show(io, v::VersionNumber) = print(io, "v\"", v, "\"")
It seems at this moment you decide whether you want to rely on one common function; you simply implement all such functions in this way. Example:
type Foo end import Base.string function string(x::Foo) return "a Foo()" end import Base.print print(io::IO, x::Foo) = print(io, string(x)) import Base.show show(io::IO, x::Foo) = print(io, "This is ", x)
-
julia> f = Foo() This is a Foo()
lgautier
source share