Compile / runtime differences for using import statements
Adam D Ruppe
destructionator at gmail.com
Fri Apr 21 00:15:27 UTC 2023
On Thursday, 20 April 2023 at 23:04:14 UTC, Selim Ozel wrote:
> I've been wondering if there is any difference between
> importing a function/component from a module as stand-alone or
> importing the whole thing makes any difference.
There's no difference at link or runtime.
The only difference is how the name works. The selective imports
work as if you wrote:
static import std.stdio;
alias writeln = std.stdio.writeln;
So the module is always imported as a whole but then the names
are hidden except for the one you specified. But the one you
specified gets some weird treatment because the compiler really
does treat it as if you wrote a local alias, so it can get
priority over names from other imports when disambiguating.
More information about the Digitalmars-d
mailing list