|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - Theory question
Are there any cases where the following cases both compile but are not
identical?
A a;
B b;
a = b;
a.Foo();
//// and
A a;
B b;
a = b;
b.Foo();
The reason I ask is I'm wondering if making the type (and value) of an
assignment
expression the right hand side rather than the left hand side would silently
break code. It would be handy for cases like this because it avoids the need
for a temp variable:
class C { }
class D : C { int i();}
D newD();
C c;
void main()
{
(c = newD()).i();
}
May 21 2009
BCS wrote:Are there any cases where the following cases both compile but are not identical? A a; B b; a = b; a.Foo(); //// and A a; B b; a = b; b.Foo(); May 21 2009
Reply to Frits,BCS wrote:Are there any cases where the following cases both compile but are not identical? A a; B b; a = b; a.Foo(); //// and A a; B b; a = b; b.Foo(); May 21 2009
|