Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show with Type{T <: X} messes with Base.show #12456

Closed
SimonDanisch opened this issue Aug 4, 2015 · 6 comments
Closed

Show with Type{T <: X} messes with Base.show #12456

SimonDanisch opened this issue Aug 4, 2015 · 6 comments

Comments

@SimonDanisch
Copy link
Contributor

Hi,
just run into the following:

abstract Mesh

function Base.show{M <: Mesh}(io::IO, ::Type{M})
end

julia> println(methods(similar))
#42 methods for generic function "similar":
similar(r::Range{T}, T::Type{T}, dims::Tuple{Vararg{Int64}}) at range.jl:252
similar(r::Range{T}, T::Type{T}, dims::Tuple{Vararg{Integer}}) at range.jl:251
similarERROR: type DataType has no field body
 in show at show.jl:76 (repeats 2 times)
 in show_delim_array at show.jl:219
 in show at show.jl:73
 in show_type_parameter at show.jl:82
 in show at show.jl:92
 in show_type_parameter at show.jl:82
 in show at show.jl:92
 in show at expr.jl:56
 in show_type_parameter at show.jl:82
 in show at show.jl:92
 in print at strings/io.jl:5
 in print_to_string at strings/io.jl:19
 in argtype_decl at methodshow.jl:26
 in arg_decl_parts at methodshow.jl:38
 in show at methodshow.jl:44
 in show_method_table at methodshow.jl:69
 in print at strings/io.jl:5
 in print at strings/io.jl:6
 in println at strings/io.jl:8
 in println at stream.jl:242
 in println at strings/io.jl:11

Am I using some forbidden technique, or is this simply a bug?!

versioninfo()
Julia Version 0.4.0-dev+6492
Commit a6c78b6* (2015-08-04 07:48 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Best,
Simon

@timholy
Copy link
Member

timholy commented Aug 4, 2015

It's generally fine to play with show for values, but messing with show for types is frowned upon (speaking as the subject of the frowning).

@SimonDanisch
Copy link
Contributor Author

I see... Still, there is a difference between frowned uppon and destroying
Base functionality.
So should it be deprecated? I'm not really seing the point though, besides
making show more predictable to the user.

From how I see it, show does not give any guarantees like "this yields
always the same printout for any type", though. So I'm not sure why it
should be different for types.

Why don't we let users overload show and use dump/xdump for the full
description?

The printout of my Mesh type is pretty much unusable without overloading
it.

On 4 Aug 2015 20:24, "Tim Holy" [email protected] wrote:

It's generally fine to play with show for values, but messing with show
for types is frowned upon
JuliaMath/FixedPointNumbers.jl#9 (comment)
(speaking as the subject of the frowning).


Reply to this email directly or view it on GitHub
#12456 (comment).

@Keno
Copy link
Member

Keno commented Aug 5, 2015

If it's legal to define, it should not mess with Base printing, so this is a bug.

@simonster
Copy link
Member

In any case it seems like it's probably a bad idea to define because it will cause show to be specialized/compiled for each type-valued argument it may be called on, instead of just being specialized/compiled once for DataType.

@JeffBezanson
Copy link
Member

Looks similar to #8163

@vtjnash
Copy link
Member

vtjnash commented Apr 22, 2016

this was fixed along with #8163

@vtjnash vtjnash closed this as completed Apr 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants