[Issue 6043] New: Chainable template mixin
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat May 21 16:48:06 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6043
Summary: Chainable template mixin
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-05-21 16:43:54 PDT ---
I suggest to add something like this to D2 Phobos (this is D1 code):
template Chainable() {
Chain!(typeof(this), Range) opCat(Range)(Range r) {
return chain(this, r);
}
}
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 an useful optimization.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list