This is appreciated just when showing the function, methods(f) is correct:
julia> foo() = :foo
foo (generic function with 1 method)
julia> foo() = :foo
WARNING: Method definition foo() in module Main at REPL[56]:1 overwritten at REPL[56]:1.
foo (generic function with 2 methods)
julia> foo() = :foo
WARNING: Method definition foo() in module Main at REPL[56]:1 overwritten at REPL[56]:1.
foo (generic function with 3 methods)
julia> foo() = :foo
WARNING: Method definition foo() in module Main at REPL[56]:1 overwritten at REPL[56]:1.
foo (generic function with 4 methods)
julia> methods(foo)
# 1 method for generic function "foo":
foo() in Main at REPL[56]:1
julia> foo
foo (generic function with 4 methods)
julia> VERSION
v"0.6.0-dev.1781"
This isn't wrong. The four are all callable
But it's misleading that display says one thing and methods another. Maybe we need to tell it has 1 method with 4 versions?
julia> methods(foo)
# 1 method for generic function "foo":
foo() in Main at REPL[56]:1
julia> foo
foo (generic function with 1 method and 4 versions)
Something like that makes more sense to me IMHO.
This isn't wrong. The four are all callable
How can they be called?
How can they be called?
If some code was executing in the corresponding world, calling foo in that world will run the corresponding method.
I also think this is a bug. Calling methods(f) implicitly passes a world number, and the result is for that world. The method count should use the equivalent of length(methods(f)). The default behavior should be to give results for a specific default world.
would you object to us instead always printing the world counter:
# 1 method for generic function "foo" *in the current world*:
# 1 method for generic function "foo" *in world 12345*:
Altering the count to exclude methods with max-age cutoffs shouldn't be hard either.
I think "in the current world" should be the default, and therefore implied, so it doesn't need to be printed.
Is there documentation about worlds somewhere?
@dpsanders there is a new Redefining Methods subject in the Methods chapter of the manual:
Closed by #19889.
Most helpful comment
Is there documentation about worlds somewhere?