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

Nick Sabalausky a at a.a
Fri Nov 13 14:06:13 PST 2009


"bearophile" <bearophileHUGS at lycos.com> wrote in message 
news:hdkavm$1b0k$1 at digitalmars.com...
> 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: *;
>
> Every part of a language needs to be designed with care. Approximate 
> designs with several holes aren't enough.
>

I used to think so, but I'm not so sure anymore. In my Goldie project, one 
of the modules ("goldie.file") is something with a whole lot of types and 
details about loading a .cgt file. In the vast majority of use-cases, the 
Goldie library user has no reason to use any of those directly, so as useful 
as "goldie.all" is, it would be pointless for me to include that 
"goldie.file" in "goldie.all", which is exactly what "goldie.*" would do 
automatically if it existed. Now, certainly, I could just mark everything in 
"goldie.file" as private, but I do want people to be able to import and use 
it directly if they want to (Ex, if they want to use Goldie as a springboard 
for their own .cgt-file handling routines).

Plus, I'll often have renamed and deliberately unused source files in the 
same directory as "real" modules, and I wouldn't want them automatically 
grabbed by ".*". I suppose I could change their extension, but then the 
editor would get confused, and I'd have to work around that, etc... 





More information about the Digitalmars-d mailing list