Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
January 20, 2012 [Issue 7330] New: Local imports are order sensitive | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=7330 Summary: Local imports are order sensitive Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: peter.alexander.au@gmail.com --- Comment #0 from Peter Alexander <peter.alexander.au@gmail.com> 2012-01-20 12:54:07 PST --- According to the language reference: "The order in which ImportDeclarations occur has no significance." This is true for module scope imports in DMD (2.057 tested), but not for function scope imports. --- import std.stdio; void main() { writeln("foo"); //ok } --- void main() { writeln("foo"); //ok } import std.stdio; --- void main() { import std.stdio; writeln("foo"); // ok } --- void main() { writeln("foo"); // error, writeln undefined import std.stdio; } --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 20, 2012 [Issue 7330] Local imports are order sensitive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=7330 timon.gehr@gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timon.gehr@gmx.ch --- Comment #1 from timon.gehr@gmx.ch 2012-01-20 13:55:42 PST --- I think what is meant in the reference is that the relative order of multiple ImportDeclarations is insignificant. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 21, 2012 [Issue 7330] Local imports are order sensitive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=7330 --- Comment #2 from Peter Alexander <peter.alexander.au@gmail.com> 2012-01-20 16:51:52 PST --- (In reply to comment #1) > I think what is meant in the reference is that the relative order of multiple ImportDeclarations is insignificant. True, it could be interpreted that way. My understanding with D (in general) is that the ordering of all declarations is supposed to be inconsequential. If this isn't the case and the code is in error by design then it should be clarified, especially since it is inconsistent with import declarations at module scope. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 21, 2012 [Issue 7330] Local imports are order sensitive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=7330 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg@gmx.com --- Comment #3 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-01-20 17:21:42 PST --- Yeah. I don't think that this is a bug, but then again, I wouldn't have been surprised if it didn't work to put imports at module scope after the line where you use what you're importing. It would just be so bizarre to put the imports anywhere but at the top that I've never thought about it. But consider that the order of declarations of module variables doesn't normally matter (it can with static if), but it matters a great deal at local scope. So, for imports to work the same makes sense. I'm not quite sure how the language spec would be updated though. I don't know how you could have interpreted it to mean that you could put them after the line where you used what you're importing within a function. I would have thought that it was crystal clear as it is. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 21, 2012 [Issue 7330] Local imports are order sensitive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=7330 --- Comment #4 from timon.gehr@gmx.ch 2012-01-20 17:54:22 PST --- Also see issue 7329. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 24, 2012 [Issue 7330] Local imports are order sensitive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=7330 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |spec CC| |bugzilla@digitalmars.com --- Comment #5 from Peter Alexander <peter.alexander.au@gmail.com> 2012-01-21 03:51:22 PST --- (In reply to comment #3) > I'm not quite sure how the language spec would be updated though. I don't know how you could have interpreted it to mean that you could put them after the line where you used what you're importing within a function. I would have thought that it was crystal clear as it is. Well, it can't be crystal clear because you were unaware that you could put imports at module scope after the use of the imported symbols :-) One way would be to add a statement to the effect of: "At module scope, import declarations may appear after the use of imported symbols. However, in local scopes, import declarations must appear before the use of any symbols introduced by the import." -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 14, 2012 [Issue 7330] Local imports are order sensitive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=7330 dawg@dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |dawg@dawgfoto.de Resolution| |INVALID --- Comment #6 from dawg@dawgfoto.de 2012-02-14 06:16:48 PST --- This is according to specs. https://github.com/D-Programming-Language/d-programming-language.org/blob/master/module.dd#L366 -- 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