How about Go's... error on unused imports?

Leandro Lucarella llucax at gmail.com
Sat Nov 14 09:51:18 PST 2009


Walter Bright, el 13 de noviembre a las 20:56 me escribiste:
> Leandro Lucarella wrote:
> >Walter Bright, el 13 de noviembre a las 18:17 me escribiste:
> >>bearophile wrote:
> >>>Clay Smith:
> >>>
> >>>>I would like my all.d files to not give errors :o<
> >>>"all.d" files are a hack used to patch one of the minor holes of the
> >>>current D module system. The right way to do that is with a syntax
> >>>like (that must not import the 'foo' name too in the current
> >>>namespace, only the names inside "std.foo"):
> >>>
> >>>import std.foo: *;
> >>Sorry, I think that * approach is far worse as you never can be sure
> >>what it is picking up.
> >
> >!? import std.foo: *; is the current behavior for import std.foo;!
> 
> I thought you were asking for all .d files in the directory foo?

Nope. Bug 3504 is about this:

mod.d:
        void f() {}

pkg/a.d:
        void f() {}

pkg/pkg.d:
        void f() {}

x.d:
        import mod: *;
        import pkg: *;

        void main() {
                f();     // mod.f
                a.f();   // pkg.a.f
                pkg.f(); // pkg.pkg.f
        }

I added the example to the bug report for clarification.
http://d.puremagic.com/issues/show_bug.cgi?id=3504

Here is an example if all 3503, 3504 and 3505 gets implemented:

mod.d:
    void f() {}

pkg/a.d:
    void f() {}

pkg/pkg.d:
    void f() {}

some/large/package/a_module.d:
    void f() {}

x.d:
1   import mod: *; // doesn't introduce the symbol 'mod'
2   import pkg: *; // introduce the symbol 'pkg' but refering to pkg.pkg
3   import some.large.package.a_module; // introduce the symbol 'a_module'
4   static import some.large.package.a_module;
5
6   void main() {
7       f();          // mod.f (from line 1)
8       a.f();        // pkg.a.f (from line 2)
9       pkg.f();      // pkg.pkg.f (from line 2)
10      a_module.f(); // some.large.package.a_module (from line 3)
11      some.large.package.a_module.f(); // (from line 4)
12  }

I added this example to bug 3503, which is the one that makes 3504 and
3505 more useful.
http://d.puremagic.com/issues/show_bug.cgi?id=3503


Does this makes more sense?

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
No recuerdo las flores, no conozco el viento
Aquí donde envejecen juntos presos y carceleros
Los días no pasan, el tiempo no pasa
Y vivimos contando el tiempo
Y moriremos contando el tiempo



More information about the Digitalmars-d mailing list