I’ve read the Julia reference section on modules carefully but I still don’t understand exactly what’s going on below. These are two separate sessions.
# Create a simple type and define show() for it. julia> struct Foo <: Integer x end julia> show(z::Foo) = print(z) show (generic function with 1 method) julia> show(0) ERROR: MethodError: no method matching show(::Int64) You may have intended to import Base.show Closest candidates are: show(::Foo) at REPL:1 Stacktrace:  top-level scope at none:0 julia>
julia> show(0) 0 julia> struct Foo <: Integer x end julia> show(0) 0 julia> show(z::Foo) = print(z) ERROR: error in method definition: function Base.show must be explicitly imported to be extended Stacktrace:  top-level scope at none:0 julia>
I understand that if I want to extend
Base.show I should import it, but I don’t understand exactly what’s going on here. The manual says that in all Julia sessions
using Base is done implicitly to make Base’s methods available, and that Base’s methods are available for extension. In the first session I can define show on my type without conflict but Base.show is not available via default. In the second session, invoking show(0) seems to have bound show() to Base.show such that extending it with my type causes an error. Can someone explain in more detail the process?