I just stumbled upon the following very interested idea:
http://forum.dlang.org/thread/[email protected]%2Fissues%2F
1. Add the following (where?)
template Chainable() {
Chain!(typeof(this), Range) opCat(Range)(Range r) {
return chain(this, r);
}
}
2. Then in the body of a lazy range both Phobos ones like map,
filter, zip, iota, and so on, and user-defined ones, you may add:
mixin Chainable;
This allows to write more natural and readable code like:
iota(5) ~ filter!q{a}([1,0,3])
map!abs([1,2,-5]) ~ [10, 20]
instead of more noisy:
chain(iota(5), filter!q{a}([1,0,3]))
chain(map!abs([1,2,-5]), [10, 20])
See also bug 5638 for a useful optimization.
I'd be glad to work on Phobos PR for this :)