On Tuesday, 1 September 2015 at 15:50:40 UTC, jmh530 wrote:
I'm following some of your post, but not quite all of it (particularly the part at the end, and I also think static imports can't be selective). Anyway, I was thinking about something like below as one possible alternative

struct T
{
        import local : S;
        void foo(S s)
        {
                import std.stdio : writeln;
                writeln(s.a);
        }
}

Bad idea to wrap it in a struct like that.

An alternative to static import would be to `import loc = local;` which introduces `loc` but doesn't go further; everything in `local` has to be qualified as `loc.*`.

They aren't selective, yeah. But the rationale is good: There's not supposed to be any way to import modules with the same path so static importing means it's entirely and always unambiguous.

The idea was to static import 'local' (to introduce the 'local' name itself into scope), which lets you use its contents only fully-qualified and, basically solves your issue. You could still `import local;` inside the function to use its contents unqualified.

Reply via email to