phobos dependencies
Martin Nowak
code at dawg.eu
Fri Dec 20 12:43:07 PST 2013
On 12/20/2013 06:27 PM, Andrei Alexandrescu wrote:
>
> I had this idea fot a while, and Walter is favorable of it as well -
> extend "import" for one-shot use. With that feature the example would
> become:
>
> void topN(alias less = "a < b",
> SwapStrategy ss = SwapStrategy.unstable,
> Range, RandomGen)(Range r, size_t nth, ref RandomGen rng)
> if (isRandomAccessRange!(Range) && hasLength!Range
> && import.std.random.isUniformRNG!RandomGen)
> { ... }
>
> In this case "import" would syntactically be placed at the beginning of
> a qualified name, meaning "import this module lazily and look up the
> symbol in it".
>
> This would simplify quite a lot of two-liners into one-liners in other
> places, too.
The fact that template constraints use the module scope is indeed a root
cause for a lot of module dependencies, so we should tackle this problem
specifically.
Couldn't static imports be made lazy without breaking any code?
The above example would read.
static import std.range.
void foo(R)(R range) if (std.range.isForwardRange!R)
{
}
More information about the Digitalmars-d
mailing list