[Issue 7702] opDispatch & opCall errors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 13 07:30:41 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7702
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2012-03-13 07:30:50 PDT ---
The infinite loop in dmd is the real issue.
struct S {
template opDispatch (string name) {
//void opCall (T) () @property {} // not need
}
}
void main () {
S s;
s.x!int; // infinite loop in dmd
}
And others are not errors, because their error messages are valid.
Then I replace the subject.
----
opCall works only for call syntax, e.g. rewriting foo(args) to
foo.opCall(args).
If you want to implement s.x!int with opDispatch, *nested opDispatch idiom*
like follows would work.
struct S {
template opDispatch(string name) {
T opDispatch(T)() @property {
return T.init;
}
}
}
void main() {
S s;
assert(s.x!int == 0);
// same as s.opDispatch!("x").opDispatch!(int)()
}
--
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