[Issue 8463] New: Nested template static struct should work as like module level ones
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jul 29 10:30:34 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8463
Summary: Nested template static struct should work as like
module level ones
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-07-29 10:30:32 PDT ---
Voldemort type is fine idiom, but which cannot control the *nested-ness* of
inner struct completely, with current dmd.
I think 'static nested template struct' should work.
template map(alias pred) {
auto map(Range)(Range input) {
static struct Result(alias pred) {
Range input = r;
this(Range r) { input = r; }
auto empty() { return r.empty; }
auto front() { return pred(r.front); }
void popFront() { r.popFront(); }
}
return Result!pred(input);
}
}
In above code:
1. the struct Result should not require the context of map function.
2. If pred requires a context, Result is implicitly treated as nested struct.
3. And Result can access the type 'Range' in accordance with lexical scope
rule.
--
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