Reputation: 3140
When import
ing 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?
Upvotes: 3
Views: 84
Reputation: 2390
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.
Upvotes: 2
Reputation: 48196
size of the binary will be unchanged, (each import module is linked to a .d file and will be compiled and linked in whole), the linker doesn't take imports into account when culling unused code
compilation time might be a bit faster on account of not needing to fill out a large symbol table
Upvotes: 3