JuliaCloud / XMLDict.jl

XMLDict implements a simple Associative interface for XML documents.
Other
33 stars 11 forks source link

override show, not display #7

Closed stevengj closed 7 years ago

stevengj commented 7 years ago

5d3f89da2796f75cd48a0482f83cd36808844991 is incorrect: you should not override display.

As explained in the Julia manual, you should override show.

Base.show(io::IO, x::XMLDictElement) = show(io, x.x)
stevengj commented 7 years ago

Overriding display like you did here "works" for the REPL, but breaks IJulia. Even in the REPL, it breaks e.g. print:

julia> print(xml)
ERROR: MethodError: no method matching start(::XMLDict.XMLDictElement)
Closest candidates are:
  start(::SimpleVector) at essentials.jl:259
  start(::Base.MethodList) at reflection.jl:560
  start(::ExponentialBackOff) at error.jl:107
  ...
Stacktrace:
 [1] show(::Base.TTY, ::XMLDict.XMLDictElement) at ./dict.jl:34
 [2] print(::Base.TTY, ::XMLDict.XMLDictElement) at ./strings/io.jl:29
 [3] print(::XMLDict.XMLDictElement) at ./coreio.jl:4