digitalmars.D.bugs - [Issue 8062] New: UFCS and operator overloading
- d-bugmail puremagic.com (35/35) May 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8062
- d-bugmail puremagic.com (12/12) May 31 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8062
- d-bugmail puremagic.com (11/15) Jun 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8062
- d-bugmail puremagic.com (8/14) Jun 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8062
- d-bugmail puremagic.com (10/13) Jun 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8062
- d-bugmail puremagic.com (8/19) Jun 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8062
http://d.puremagic.com/issues/show_bug.cgi?id=8062 Summary: UFCS and operator overloading Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: jens.k.mueller gmx.de According to TDPL (p. 388, Table 12.1) a + b is rewritten to a.opBinary!("+")(b) or b.opBinaryRight!("+")(a) Considering operator overloading together with UFCS leads to the following wrong behavior. struct Foo {} Foo opBinary(string op)(Foo lhs, Foo rhs) if (op == "+") { return Foo.init; } unittest { Foo a, b; a + b; // fails to compile even though it should } If a + b is rewritten to a.opBinary!("+")(b) first, then UFCS should rewrite it further to opBinary!("+")(a,b). But it seems UFCS is not considered. UFCS should be carried out when the operator is being rewritten. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8062 Dmitry Olshansky <dmitry.olsh gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dmitry.olsh gmail.com 06:21:54 PDT --- As defined t shouldn't: UFCS presently only does go from fn(a,b, ...) -> a.fn(b, ...); way. And arguably rightfully so, as it already may introduce some hijacking. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8062 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timon.gehr gmx.chAs defined t shouldn't: UFCS presently only does go from fn(a,b, ...) -> a.fn(b, ...); way.Well, no. UFCS transforms a.fn(b, ...) to fn(a,b, ...).And arguably rightfully so, as it already may introduce some hijacking.-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 13 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8062 12:22:05 PDT ---My bad, I actually meant it a.fn ---> fn(a,...) way. Which brings us to the point - request is Invalid then? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------As defined t shouldn't: UFCS presently only does go from fn(a,b, ...) -> a.fn(b, ...); way.Well, no. UFCS transforms a.fn(b, ...) to fn(a,b, ...).
Jun 13 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8062My bad, I actually meant it a.fn ---> fn(a,...) way. Which brings us to the point - request is Invalid then?I don't think it is invalid. a + b -> a.opBinary!"+"(b) -> opBinary!"+"(a, b); Probably this is on the borderline between bug and enhancement request -- I think the documentation can be interpreted either way. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 13 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8062Which documentation are you referring to? I don't think this is an enhancement. How can it be an enhancement? Are there exceptions when UFCS has to be applied? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------My bad, I actually meant it a.fn ---> fn(a,...) way. Which brings us to the point - request is Invalid then?I don't think it is invalid. a + b -> a.opBinary!"+"(b) -> opBinary!"+"(a, b); Probably this is on the borderline between bug and enhancement request -- I think the documentation can be interpreted either way.
Jun 13 2012