November 14, 2009 [Issue 3506] New: [module] Imports should be valid at any scope | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Leandro Lucarella <llucax@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: ------- |
February 14, 2012 [Issue 3506] [module] Imports should be valid at any scope | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | 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 --- Comment #1 from dawg@dawgfoto.de 2012-02-14 05:40:37 PST --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation