digitalmars.D - Uniform call syntax for operator overloads
- Tomek =?UTF-8?B?U293acWEc2tp?= (10/10) Jul 25 2010 This doesn't work:
- bearophile (4/6) Jul 25 2010 That's cute, but in D overloaded operator can be defined inside structs/...
- Tomek =?UTF-8?B?U293acWEc2tp?= (4/11) Jul 25 2010 Yeah, I know, but why? What bad would happen if operators could be writt...
- Daniel Keep (4/18) Jul 27 2010 Universal Call Syntax is actually just a really old bug in method lookup
This doesn't work: int opIndex(int[][] m, uint i, uint j) { return m[i][j]; } unittest { auto m = [[9,8], [2,3]]; auto a = m[0,1]; } It's so by design or by bug? Tomek p.s. Where on D page is uniform call syntax documented? Couldn't find it in functions section.
Jul 25 2010
Tomek S.:This doesn't work: int opIndex(int[][] m, uint i, uint j) { return m[i][j]; }That's cute, but in D overloaded operator can be defined inside structs/classes/unions only (this is different from C++). Bye, bearophile
Jul 25 2010
bearophile wrote:Tomek S.:Yeah, I know, but why? What bad would happen if operators could be written down with functions-as-members syntax? TomekThis doesn't work: int opIndex(int[][] m, uint i, uint j) { return m[i][j]; }That's cute, but in D overloaded operator can be defined inside structs/classes/unions only (this is different from C++).
Jul 25 2010
Tomek SowiĆski wrote:bearophile wrote:Universal Call Syntax is actually just a really old bug in method lookup for arrays that was never fixed on account of being useful. That it doesn't work for operators is hardly surprising.Tomek S.:Yeah, I know, but why? What bad would happen if operators could be written down with functions-as-members syntax? TomekThis doesn't work: int opIndex(int[][] m, uint i, uint j) { return m[i][j]; }That's cute, but in D overloaded operator can be defined inside structs/classes/unions only (this is different from C++).
Jul 27 2010