Namespacing of methods

So it seems like it comes down to this:

I should think of the “object” canonically referred to as A.func basically as the methods table. This object is a singleton, in the sense that there can be an arbitrary number of references to it with different names (using A: func as foo) and in different namespaces (using A in module BB.func), but they’re all pointing to the same object. The methods table gets filled with any method definition that Julia comes across under any name, anywhere. There is no way to to prevent methods from being added to the methods table: if the compiler can see them, they’ll be added. I’m glossing over some details like the “world age counter”.

Does that sound right?

The export statement has nothing do with any of this. It’s only meaning is to inject names into a namespace when importing.

Oh, and there’s some questionable behavior of Julia checking or not checking whether exported names actually exist, but that’s an unrelated discussion :wink:

2 Likes