| 72 | | We propose to adopt the same principle for imports. That is, you can say "{{{import A.B.C}}}" so long as that is umambiguous (meaning that there is only one module A.B.C exported by any installed package). If the reference to A.B.C is ambiguous, you can qualify the import by adding "{{{from "foo"}}}". |
| | 72 | We propose to adopt the same principle for imports. That is, an import with no package specified, such as "{{{import A.B.C}}}", means: |
| | 73 | |
| | 74 | Find all modules A.B.C exported by all exposed packages, or the package or program being compiled. If there is exactly one such module, that's the one to import. Otherwise report "ambiguous import". |
| | 75 | |
| | 76 | If the reference to A.B.C is ambiguous, you can qualify the import by adding "{{{from "foo"}}}". |
| | 81 | |
| | 82 | In short, an installed package can be of two kinds: |
| | 83 | * '''Exposed''': the package's modules populate the global module namespace, and can be imported without mentioning the pacckage name explicitly ({{{import A.B.C}}}). Explicit "from" imports may be used to resolve ambiguity. |
| | 84 | * '''Available''', but not exposed: the package can be used only by an explicit "from" import. This is rather like "{{{import qualified M}}}, except at the package level. |
| | 85 | |
| | 86 | Typically, if multiple versions of the same pacakge are installed, then all will be available, but only one will be exposed. |
| | 87 | |
| | 88 | Simon suggested that an installed package might be hidden (so that it cannot be used at all) but I'm not sure why we need that. |
| | 89 | |