-
Notifications
You must be signed in to change notification settings - Fork 114
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
Consider deleting custom show methods for types #321
Comments
The docs really need to change then, because this section clearly overloads https://docs.julialang.org/en/v1.4/manual/types/#man-custom-pretty-printing-1 |
Defining |
Oh, right, sorry for the noise. I need to read more carefully. |
Old history here: JuliaLang/julia#13306. Not sure how much of a modern problem it is, but I've been paranoid about specializing I wonder if we need |
It would be very useful to have something like |
Overloading `show` for types is strongly discouraged. I'm currently tracking down a Julia segfault that's caused by this line. Refs: - JuliaMath/FixedPointNumbers.jl#11 - PainterQubits/Unitful.jl#321
* upstream/master: (22 commits) Fix printing of complex and logarithmic quantities (PainterQubits#366) Remove @_doctables (PainterQubits#363) Fix a doctest (PainterQubits#365) Release v1.3.0 Add page headers to documentation (PainterQubits#361) Fix link to documentation in README.md: latest -> dev. (PainterQubits#360) Properly document Quantity constructor (PainterQubits#357) Delete show(::IO, ::Type) methods. Closes PainterQubits#321 (PainterQubits#322) Throw error for div etc. with affine quantities (PainterQubits#354) Fixes for the documentation (PainterQubits#356) Enable Travis on macOS (PainterQubits#355) Switch to a more standard Documenter setup (PainterQubits#353) Update repo URL (PainterQubits#352) Delete duplicate @affineunit docstring in the documentation (PainterQubits#349) Fix some doctests (PainterQubits#345) Add AbstractQuantity docstring to docs (PainterQubits#351) Provide Base.isless() for LogScaled values (PainterQubits#315) Small fixes to documentation (PainterQubits#341) Add CompatHelper, reduce frequency of TagBot to once per day (PainterQubits#337) Fix conversion of fractional units (PainterQubits#335) ...
I.e.
Unitful.jl/src/display.jl
Lines 80 to 85 in 7fb2dfb
The first is that, according to the compiler team, the base methods are not supposed to be overloaded. It's not documented and not obvious but it's been assumed that
show(::IO, ::Type)
isn't overloaded by user code so doing that can lead to very odd issues. E.g. the definitions in this package might have caused Documenter to hang for one of my packages because Documenter prints the signature of methods with missing docs.The second reason is that it can be super confusing when types print differently from what they really are. I've had some issues with that when using this package because I based some function signatures on how the types were printed in the REPL only to get an error because the signature didn't match.
The text was updated successfully, but these errors were encountered: