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

Leandro Lucarella llucax at gmail.com
Fri Nov 13 15:07:24 PST 2009


bearophile, el 13 de noviembre a las 14:10 me escribiste:
> 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.

That's true, I like the Google's Go aproach: no modules, just packages.
All files in a directory are part of the same packages, so you can split
a package in several files without increasing the packages system nesting
level too much (as it happens in D).

But "fixing" the D module system is too big, so I'm asking only to flag
unused imports for now ;)

I *really* like the interfaces+embedding of Google's Go, it's similar to
interfaces+mixins in D, but taken a little further, but that's a very big
change too and I don't think D will ever take that road.

Too bad.

> 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: *;

I like very much this too about Google's Go: when importing a nested
package, to use its symbols you just have to type the leaf:

import "std/foo";

foo.Something(); // instead of std.foo.Something();

This helps a lot with large names and, in conjuntion with packages being
distributable among multiple files, removes the need for an import
foo.all;

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
For long you live and high you fly
But only if you ride the tide
And balanced on the biggest wave
You race towards an early grave.



More information about the Digitalmars-d mailing list