digitalmars.D.bugs - [Issue 3506] New: [module] Imports should be valid at any scope
- d-bugmail puremagic.com (33/33) Nov 13 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3506
- d-bugmail puremagic.com (22/22) Feb 14 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3506
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 puremagic.com ReportedBy: llucax gmail.com 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: -------
Nov 13 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3506 dawg dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |dawg dawgfoto.de Resolution| |WORKSFORME cat > foo.d << CODE void bar() {} CODE cat > ut.d << CODE unittest { import foo; foo.bar(); } CODE dmd -c -unittest ut.d -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2012