digitalmars.D.learn - Does selective imports have an effect on the resulting executable?
- Gary Willoughby (10/10) Nov 28 2013 Does selective imports have an effect on the resulting
- Adam D. Ruppe (5/7) Nov 28 2013 No, I don't think so. The compiler still reads the module and the
- Dicebot (7/17) Nov 28 2013 No, selective imports are just matter of namespace hygiene and
Does selective imports have an effect on the resulting executable? For example if i included the following at the top of my source to only include one function from a library: import std.algorithm : reduce; Would it have any impact on the resulting executable? i.e. only include compiled code for the selected functions? If i imported the whole library like this: import std.algorithm; Is it more wasteful? Not as optimised? Any draw backs? Bigger executable?
Nov 28 2013
On Thursday, 28 November 2013 at 12:31:11 UTC, Gary Willoughby wrote:Does selective imports have an effect on the resulting executable?No, I don't think so. The compiler still reads the module and the linker still sees the whole object file to do its thing, it just doesn't bring all the names into scope.
Nov 28 2013
On Thursday, 28 November 2013 at 12:31:11 UTC, Gary Willoughby wrote:Does selective imports have an effect on the resulting executable? For example if i included the following at the top of my source to only include one function from a library: import std.algorithm : reduce; Would it have any impact on the resulting executable? i.e. only include compiled code for the selected functions? If i imported the whole library like this: import std.algorithm; Is it more wasteful? Not as optimised? Any draw backs? Bigger executable?No, selective imports are just matter of namespace hygiene and code readability. Scope-local imports , however, can impact resulting executable a lot if used inside templated scopes (nothing will be imported at all if it is not instantiated)
Nov 28 2013