Search code examples
importd

D: What is the difference between targeted and general imports?


When importing something into a D module, you can either write

import std.string;

or

import std.string: format;

Apart from the obvious semantic differences, does this have any other effects? For example, size of the binary, compilation time, something else?


Solution

  • I would add to ratchet freak's answer that named import (or wathever the name) avoids name clash. Having just what you need in the current scope when coding is nice to avoid bug and to have more freedom when naming things. If you only use import std.string;, you won't be able to name your variables/functions succ, center, etc.