Assume there is a function F
in package A
that some code I'm creating needs to call. How do I call it?
If I'm Calling it from outside package A
, then I uses A.F(...)
and if I'm inside A
I uses F(...)
. But what if Murphy prevents me from knowing which is true or requires a byte identical line work in both?
[note: I'm taking it as a given that such a case will occur because, in my experience and observations, that is generally a safe assumption. Even in the absence of technical reasons for it, PHBs and legislators are good sources of the ridiculous.]
There is no such syntax. Observe the following things:
S
with thepkg.S
syntax because it will not be able to import itself.Even if you solved that problem, observe that packages can be given an arbitrary name once imported. For instance, you could do:
Which imports
S
from package"foo"
asbar.S
as opposed to the expectedfoo.S
.The following things could be used to work around this:
"foo"
, create an internal objectfoo
whose members are the symbolsfoo
exports. This allows you to use thefoo.S
syntax infoo
itself, but is a horrible kludge.Use an import declaration like
which allows you to use symbol
S
from package"foo"
asS
, i. e. without prefix. Notice that this kind of import declaration, called dot imports, is considered bad style and might break things if the set of symbols you declare / the package you import declares changes.