If I understand correctly, the "returned value" is really calling this:
function display(d::REPLDisplay, ::MIME"text/plain", x)
> io = outstream(d.repl)
> Base.have_color && write(io, answer_color(d.repl))
> writemime(io, MIME("text/plain"), x)
> println(io)
> end
> display(d::REPLDisplay, x) = display(d, MIME("text/plain"), x)
So there is a quick way to short-circuit the displayed value (without
changing Base for everyone else):
julia> x = one(UInt8)
> 0x01
> julia> Base.display(d::Base.REPL.REPLDisplay, x::Unsigned) = println(x)
> display (generic function with 11 methods)
> julia> x
> 1
The nicest solution (IMO) is letting a user turn on/off this functionality
dynamically for whatever types they want, and setting display format easily
for a session. I think all this belongs in Formatting, not in Base.
On Thu, Sep 17, 2015 at 8:16 AM, Sisyphuss <[email protected]> wrote:
> This is not "printing" but "returned value"
> Try `a[1]`, you get 0x0000000000000001
> Try `print(a[1])`, you get 1
>
> So overload `print` if ever needed.
>
>
> On Wednesday, September 16, 2015 at 11:34:33 PM UTC+2,
> [email protected] wrote:
>>
>> In Julia 0.4rc1, when I create a UInt, either as an individual value or
>> array, and then print it hex values are usually displayed instead of
>> decimals. I say 'usually' because the behavior changes a bit between REPL
>> and
>>
>> For instance:
>>
>> julia> a = UInt[1 2 3 4]
>> 1x4 Array{UInt64,2}:
>> 0x0000000000000001 0x0000000000000002 … 0x0000000000000004
>>
>> This annoys me because 98% of the time I want the decimal representation.
>> Decimal is shown for Int, so why is hex the default for UInt? Is it a bug?
>>
>