On Saturday, 21 December 2013 at 08:08:42 UTC, Dmitry Olshansky
wrote:
That has the disadvantage of importing the whole std.range.
I seriously doubt that we'd get anything better then:
> import std.range.traits;
>
> void foo(R)(R range) if (isForwardRange!R)
> {
import std.range;
...
> }
Stays practical w.r.t. cutting down dependencies and no need to
uglify constraints. They are not that readable already.
I agree, to an extent. That's definitely the ultimate solution
that should be taken. Smaller modules are better in general.
That said, supporting a lazy static import feature might not be a
bad idea. Then a hybrid approach could be taken, which would help
things in the short-run. Maybe doing something like this:
static import std.range;
alias isForwardRange = std.range.isForwardRange;
void foo(R)(R range) if (isForwardRange!R)
{
...
}
That would be readable now and would support easy changes to the
better packaged approach later. I'd think this would be something
possible to do in 2.066 whereas splitting up everything will
likely take several versions.