2 ms·
> I would expect that dispatching on my object should still invoke my method, but weeks is always referring to its own, I understand. Correct. But if singular
by munificent 15y ago
> I would expect that dispatching on my object should still invoke my method, but weeks is always referring to its own, I understand.
Correct. But if singular itself was publicly exported by Dates, when you defined your own specializations of it in your module, they will go into the same multimethod that Dates is using. The big limitation here is that you can't replace the version that Dates has specialized on String by specializing on the same type.
The way this works is that when you import a multimethod from another module, you're importing the exact same multimethod object that that module is using. If you then define your own specializations, the original module can see them too.
This is necessary to make overriding work at all, though it's a bit confusing in some ways. Honestly, I feel like I'm still trying to wrap my head around it too.