[Issue 3506] New: [module] Imports should be valid at any scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 13 16:37:39 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3506

           Summary: [module] Imports should be valid at any scope
           Product: D
           Version: future
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: llucax at gmail.com


--- Comment #0 from Leandro Lucarella <llucax at gmail.com> 2009-11-13 16:37:38 PST ---
Imports should be valid at any scope, like classes, structs, and functions.
This is specially useful for unit tests for example, currently this idiom is
needed:

version (unittest) import foo;

unittest {
  foo.bar();
}

It would be much nicer to be able to just write:

unittest {
  import foo;
  foo.bar();
}

This brings more locality to the code. This limitation is like C's (pre C99)
inability to add variable declarations after the first statement. It easier to
refactor code this way too, if I move the unittest (function, class or
whatever) to another file, my imports are moved too without any further work,
now I have to track all the import and remove/add appropriately.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list