On 6/16/13 6:07 AM, Timon Gehr wrote:
On 06/16/2013 11:50 AM, Tyro[17] wrote:
On 6/16/13 5:34 AM, Timon Gehr wrote:

Should be fixed for those not willing to use the mechanism
currently available to resolve the issue, but I wouldn't loose any sleep
if it weren't.


There is no mechanism in place that reliably avoids silent breakage.

A very valid point. For this particular case though, I would move to suggest that an apt resolution would be to documentation the behavior and suggest that if such behavior is not desired, the use of renamed imports or static imports is recommended for scoped imports.

        import s = std.stdio;
        import std.stdio: print = writeln;
        static import std.stdio;

any of these options is a valid solution this particular issue while documentation takes care of the rest.

Having just said that, I took a quick look at the documentation and this is what it had to say:

"In function scopes, imported symbols only become visible after the import declaration lexically appears in the function body. In other words, imported symbols at function scope cannot be forward referenced. "

Even the example given there clearly tells you this will happen:

void main() {
        void writeln(string) {}
        void foo() {
                writeln("bar"); // calls main.writeln
                import std.stdio;
                writeln("bar"); // calls std.stdio.writeln
                void writeln(string) {}
                writeln("bar"); // calls main.foo.writeln
        }
        writeln("bar"); // calls main.writeln
        std.stdio.writeln("bar"); // error, std is undefined
}

I don't see the problem.

--

Andrew Edwards
--------------------
http://www.akeron.co
auto getAddress() {
    string location = "@", period = ".";
    return ("info" ~ location ~ "afidem" ~ period ~ "org");
}

Reply via email to