D import idiom compilation time
Dgame
r.schuett.1987 at gmail.com
Wed Jan 9 22:59:59 UTC 2019
On Wednesday, 9 January 2019 at 22:39:58 UTC, Jonathan Marler
wrote:
> Make sure whoever works on it is aware of this:
>
> https://github.com/marler8997/dlangfeatures#lazy-imports
>
> To summarize, there's no way to make normal imports lazy (i.e.
> "import foo;"). However we can make the following lazy by
> default:
>
> 1. static imports (static import std.typecons;)
> 2. selective imports (import std.typecons: isBigEndian;)
> 3. aliased imports (import t = std.typecons;)
>
> I had a partial implementation for lazy imports, but Walter
> never reviewed my other pull requests so I never pushed it.
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?
Example:
----
import foo; // contains bar2
void bar1() { }
bar1(); // in current scope
bar2(); // not found, we have to search in the imports
----
More information about the Digitalmars-d
mailing list