Re: [julia-users] Inheriting from Real works, from AbstractFloat does not?
thanks On Monday, August 24, 2015 at 11:00:11 PM UTC-4, Jacob Quinn wrote: When you subtype AbstractFloat, it's going to try to use the `grisu.jl` code to do the showing. The grisu code has all sorts of requirements to work, most of it semi-hard-coded for Float16, Float32, and Float64. Your best bet would probably be to define Base.show(io::IO, x::SubtypeAbsFloat) = show(io, x.val) On Mon, Aug 24, 2015 at 8:56 PM, Jeffrey Sarnoff jeffrey...@gmail.com javascript: wrote: julia immutable SubtypeReal : Real val::Float64 end julia a=SubtypeReal(5.0) SubtypeReal(5.0) julia immutable SubtypeAbsFloat : AbstractFloat val::Float64 end julia a=SubtypeAbsFloat(5.0) Error showing value of type SubtypeAbsFloat: ERROR: - not defined for SubtypeAbsFloat in _show at grisu.jl:64 in show at grisu.jl:119 ... in run_repl at ./REPL.jl:166 in _start at ./client.jl:453 Defining show for it does not help.
Re: [julia-users] Inheriting from Real works, from AbstractFloat does not?
When you subtype AbstractFloat, it's going to try to use the `grisu.jl` code to do the showing. The grisu code has all sorts of requirements to work, most of it semi-hard-coded for Float16, Float32, and Float64. Your best bet would probably be to define Base.show(io::IO, x::SubtypeAbsFloat) = show(io, x.val) On Mon, Aug 24, 2015 at 8:56 PM, Jeffrey Sarnoff jeffrey.sarn...@gmail.com wrote: julia immutable SubtypeReal : Real val::Float64 end julia a=SubtypeReal(5.0) SubtypeReal(5.0) julia immutable SubtypeAbsFloat : AbstractFloat val::Float64 end julia a=SubtypeAbsFloat(5.0) Error showing value of type SubtypeAbsFloat: ERROR: - not defined for SubtypeAbsFloat in _show at grisu.jl:64 in show at grisu.jl:119 ... in run_repl at ./REPL.jl:166 in _start at ./client.jl:453 Defining show for it does not help.
[julia-users] Inheriting from Real works, from AbstractFloat does not?
julia immutable SubtypeReal : Real val::Float64 end julia a=SubtypeReal(5.0) SubtypeReal(5.0) julia immutable SubtypeAbsFloat : AbstractFloat val::Float64 end julia a=SubtypeAbsFloat(5.0) Error showing value of type SubtypeAbsFloat: ERROR: - not defined for SubtypeAbsFloat in _show at grisu.jl:64 in show at grisu.jl:119 ... in run_repl at ./REPL.jl:166 in _start at ./client.jl:453 Defining show for it does not help.