Last update March 7, 2012

Import Issues



Conclusion

At this time there are no significant issues with imports. The issues outlined on this page were resolved by DMD 0.163, which makes 'private import' the default, adds 'static import' to import fully qualified names, and adds syntax for importing only specific symbols. See ( NG:digitalmars.D.announce/4289) and DigitalMars:d/module.html for details.

This page remains here only for historical interest.


resolution

Import Conflict Resolution


article

http://larsivi.net/files/ImportIssues.pdf


problems:

  1. Name collisions local (owned by programmer)
  2. Name collisions external (caused by outside libraries)
  3. Name collisions from a module not imported (inherited module)
  4. Too wordy (causing inconsistency and maintainability problems)
  5. Default gotchas (cause problems or make maintainability harder)
  6. Modules inheriting 'grandparent' is unexpected with private

solutions:

Note: FQN = Fully Qualified Name

  1. static import
    1. tries to solve problem of name collisions, requiring FQN's
  2. static import by default
    1. tries to solve problem of name collisions.
  3. alias currently
    1. tries to solve problem of being too wordy, allowing a shorter name
  4. selective-importing
    1. tries to solve problem of name collisions
  5. prefix-importing (with FQN)
    1. tries to solve problem of being too wordy (a one line alias import)
    2. tries to solve problem of name collisions (use prefix instead of short name)
  6. private invisible (not visible to importing modules)
    1. tries to solve problem of name collisions by hiding modules
    2. tries to make private more intuitive
  7. private by default
    1. tries to solve the problem of name collisions
    2. tries to solve the problem of default gotchas

Syntax ideas:

  1. import std.stdio alias io
  2. import std.stdio as io
  3. import std.stdio io
  4. import std.sdtio : io;
  5. import std.stdio => io, std.string;
  6. import std.stdio(writef, writefln) => io(write, writeLine);
  7. import std.stdio(writef, writefln) => io, io(writeLine);

FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: March 7, 2012 20:40 (diff))