Looking at https://github.com/JuliaLang/julia/pull/17017, I noticed that there is room for more specialized (eg. faster) method specializations for repr()
.
julia> methods(repr)
#2 methods for generic function "repr"
repr(u::Base.Random.UUID) at random.jl:1252
repr(x) at strings/io.jl:86
The generic implementation in strings/io.jl:85 uses an IOBuffer
, so it is probably much slower than it needs to be (especially for Strings which I think could be implemented as . The documentation demands the result must be the same as repr(s::string) = s
)showall
, so testing should ensure that is still the case.
Since this function is just an alias for showall
, I propose we eliminate it.
More precisely, it's an alias for sprint(showall, ...)
, right? I agree about deprecating it, since in 0.5 what's often needed is sprint(showcompact, ...)
instead, and the fact that we have repr
can cause confusion.
It is not the case that repr(x::String) = x
, since repr
adds quotes and escaping.
@JeffBezanson Thanks for noticing. I somehow managed to convince myself that it did not, but my REPL history shows I did not actually try.
If anything, the repr
method for UUID should be removed since nothing else defines it directly. Instead it should define string
or show
. Then the UUID code is a good candidate for #5155, since AFAICT it's not used anywhere in Base.
Some of the UUID code will be needed for Pkg3, but if that itself is a package then it can have other-package dependencies that aren't all Base code.
Making this a method of string
would be the way to go here. Moving UUIDs out would be good too.
Most helpful comment
Making this a method of
string
would be the way to go here. Moving UUIDs out would be good too.