www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13253] New: use more scoped imports in phobos


          Issue ID: 13253
           Summary: use more scoped imports in phobos
           Product: D
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

There are too many unconditional global imports in phobos.

This unnecessarily slows down compilation, especially when only a single symbol
of a module is needed. Recently I speeded-up dub [1] and found that just
importing std.conv (only for to!string(__VERSION__)) already took ~150ms.
Removing the import reduced the compile times for dub's compiler probe file [2]
to ~3ms.

There are some ideas to make (static) imports lazy and we have some root to
reduce the amount of work being done when importing a module (issue 13242).

We should still try to use more scoped (function-local) imports (better yet,
scoped selective imports). Not only will this reduce compiles times for most D
project, it also clearly specifies dependencies and helps to avoid no-longer
used imports.

[1]: https://github.com/D-Programming-Language/dub/pull/388

Aug 04 2014