DIP10005: Dependency-Carrying Declarations is now available for community feedback

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 31 08:32:23 PST 2016


On Sat, 31 Dec 2016 15:05:00 +0000, Adam D. Ruppe wrote:
> static import r = std.range.primitives;

For that to pass code review, you'd need a readable name -- perhaps 
'ranges' instead of 'r' -- which makes it more obvious, more searchable, 
and more typing.

> with (import std.stdio) void process(File input) ;
> 
> Let's rewrite that to be:
> 
> template process() {
>     import std.stdio;
>     void process(File input) {
> 
>     }
> }

But that's a lot of typing, so nobody's going to do it. Just like how we 
use normal imports rather than static or selective imports everywhere. 
It's even more verbose than DIP1005.

> BTW it is my opinion that the "one file, one module" rule is a mistake.
> Even with all these things, the declarations are still not *guaranteed*
> to carry their dependencies, since top-level imports still leak in.
> Separate modules don't have that problem, and if we could just define
> several modules in one file, we'd basically destroy this DIP in one
> swift stroke.

That's rather elegant, though I don't see how you'd import a module in a 
file that defines several modules. If they were anonymous and importing 
the file gave you access to all of them, that makes sense. Otherwise it's 
tricky to figure out which sub-file modules exist.


More information about the Digitalmars-d mailing list