Neal Becker schrieb: >> No. Array references (x[i]) and attribute references (x.a) represent >> "locations". Function calls represent values. This is no different >> than the distinction between lvalues and rvalues in C. >> > > Except this syntax is valid in c++ where X() is a constructor call: > > X(whatever) += 2; is (or can be) valid c++ That's actually the less-interesting case. You would have to overload += to make it work, right? The more interesting case is when X is a function that returns a reference: int& X(int); void foo(){ X(1) += 2; } int bar, foobar; int& X(int t){ if(t) return bar; return foobar; } Here, which variable gets incremented depends on whether the t argument is true; no overloading of assignment comes into play. The trick is that C++ has functions that *return* lvalues; neither C nor Python has such things. Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4