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.
Andrei
This is problematic for dependency generation à la rdmd.
The compiler won't know the import until the lazy symbol
is used, thereby making it impossible to build all dependencies
into a library using rdmd.