August 20, 2015
https://issues.dlang.org/show_bug.cgi?id=10378

Sobirari Muhomori <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec
                URL|                            |http://dlang.org/module.htm
                   |                            |l

--- Comment #13 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
Currently documented to work this way.

--
August 21, 2015
https://issues.dlang.org/show_bug.cgi?id=10378

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|nobody@puremagic.com        |k.hara.pg@gmail.com

--- Comment #14 from Kenji Hara <k.hara.pg@gmail.com> ---
We can resolve the issue by applying some rewriting rule.

void test()
{
    import a, b;
    import c;

    stmt1;

    improt d;

    stmt2;
}

To:

void test()
{
    struct __ImportScope1 {     // internal namespace
        import a, b;
        import c;
    }
    with (__ImportScope1) {
        stmt1;

        struct __ImportScope2 {     // internal namespace
            improt d;
        }
        with (__ImportScope2) {
            stmt2;
        }
    }
}

After that, we can reuse the symbol shadowing check mechanism on WithStatement.

--
August 21, 2015
https://issues.dlang.org/show_bug.cgi?id=10378

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #15 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/4915

--
January 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #16 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Why can't locally imported symbols work exactly as globally imported symbols, but only accessible in the given scope? That is:

import std.stdio;
// import std.conv; // line 2
void func(string text) {
        import std.conv; // after this, it's like line 2 was included
        writeln(text); // because std.conv is imported "globally" it doesn't
                       // mask local var.
}
void main() {
        // line 2 isn't included inside here, because it wasn't imported.
        func("Hello world");
}

To me, the only benefit of using locally imported symbols is to make the imports implementation details for that function. Having the module just "import globally" at the right time follows the principle of least surprise (they work like all other imports).

There's another travesty this would fix. If you import another module that overloads a function in your current module, you have to *reimport the current module*. i.e.:

a.d:
module a;

void foo(int a) {}

b.d:
module b;

void foo(string s) {}

void main()
{
   import a;
   import b; // MUST include this
   foo("hi"); // for this to compile
   foo(0);
}

I admit not to knowing how easy/possible this is to do with the current front end.

--
January 19, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--- Comment #17 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
this will pollute module scope with imported symbols.

imagine that i have `mymodule.foo (float v)` function, and defined local `foo (int v)` function. with your "hidden global import" whenever i'll import "mymodule", it will add unexpected `foo` overload for the whole code.

also, it breaks "module importing orger doesn't matter" rule.

--
January 19, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #18 from timon.gehr@gmx.ch ---
(In reply to Ketmar Dark from comment #17)
> this will pollute module scope with imported symbols.
> 
> imagine that i have `mymodule.foo (float v)` function, and defined local `foo (int v)` function. with your "hidden global import" whenever i'll import "mymodule", it will add unexpected `foo` overload for the whole code.
> 
> also, it breaks "module importing orger doesn't matter" rule.


Those statements are all incorrect, so maybe you misunderstood the suggestion. The suggestion is that name lookup should behave as if the set of global imports considered depended on the local scope. The net effect is that imports never hide each other, but symbols of the current module always hide imported symbols.

--
January 19, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #19 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
ah, i see, thank you. i really misread the suggesion. still, i like Kenji's PR4915 more. ;-) i'd better see "shadowing error", so i can simply rename symbols, and don't guess if there is conflict or not.

--
January 20, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #20 from Steven Schveighoffer <schveiguy@yahoo.com> ---
(In reply to Ketmar Dark from comment #19)
> ah, i see, thank you. i really misread the suggesion. still, i like Kenji's PR4915 more. ;-) i'd better see "shadowing error", so i can simply rename symbols, and don't guess if there is conflict or not.

Yes, thank you Timon for explaining better.

The main reason I see local imports being useful is this:

import somemodule;

void foo()
{
   onlyPlaceSomeModuleIsUsed()
}

Now, one can simply say "wait, somemodule isn't something everyone in the file needs, just foo. I'll move it inside"

And then it breaks. I'd rather just see it work the same. All you are doing is saying who has access to somemodule's symbols, and avoid polluting the module namespace.

--
January 21, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bheads@moxiegroup.com

--- Comment #21 from hsteoh@quickfur.ath.cx ---
*** Issue 15567 has been marked as a duplicate of this issue. ***

--
February 12, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #22 from Walter Bright <bugzilla@digitalmars.com> ---
Alternative implementation: https://github.com/D-Programming-Language/dmd/pull/5445

--