D import idiom compilation time

Neia Neutuladh neia at ikeran.org
Wed Jan 9 23:14:09 UTC 2019


On Wed, 09 Jan 2019 22:59:59 +0000, Dgame wrote:
> Maybe I'm missing something, but wouldn't it be possible to lazy import
> `import foo;` if the compiler checks lazily if a symbol isn't found in
> the current scope and only then tries to find it in one of the imports?
> Or would that be ineffective?

If you import two modules and both define functions named `write`, it is 
an error to use that function without somehow disambiguating. With every 
module import being lazy, it would only be an error if you had previously 
used symbols from both of those modules, and otherwise you'd get the 
function from whichever module has already been loaded.


More information about the Digitalmars-d mailing list