Implementing module, MethodError: objects of type Module are not callable

I was wrong earlier, you can assign a : variable. That’s not necessarily the same as overloading, though, it depends on if you explicitly used or imported : from Base. If you don’t, the : variable is totally separate from Base.:(:). This is an example of overloading the : in Base:

julia> :
(::Colon) (generic function with 15 methods)

julia> Base.:(:)() = 0

julia> :
(::Colon) (generic function with 16 methods)

Here’s another in a fresh session:

julia> :
(::Colon) (generic function with 15 methods)

julia> import Base: :

julia> (:)() = 0
(::Colon) (generic function with 16 methods)

Don’t actually do these methods, though, you should have 2-3 arguments with custom types to properly use the : syntax.

1 Like