Hi !
I have a problem which I thought should never happen with Julia. The result is even worse when using Pluto.
I use two modules, which have a function with the same name, but taking parameters of different types. I thought that using
them at the same time would create several methods for the same function, and that all would be good… not so.
Specifically, consider
using AbstractAlgebra # I use the permutations defined there
p= perm"(1,2,3)"
cycles(p) # this works, so far
So this works. But suppose that I try
using Permutations # also defines permutations,
# and also has a function 'cycles'
# so this issues a warning
q= Permutation([3,2,1])
cycles(q) # fails
This fails with ERROR: MethodError: no method matching cycles(::Permutation)
. Why doesn’t the second using
statement merely add a method to the function cycles
?
This seems to work routinely in other contexts, like the *
operator having more and more methods as we import more modules. In fact, these two modules above do define *
for their respective permutations, and all works fine.
(One guess: people write function Base.*
or something, letting Julia know explicitly what they want to achieve. But surely this cannot be the only way to add methods to a function, this would bring many questions, that I save for later…)
When i try all this under Pluto, things are actually worse : after the second using
statement, even the first cycles
function is “broken” – that is, calling cycles(p)
fails with UndefVarError: cycles not defined
.
So weird… ideas, anyone?
thanks!
Pierre