Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed0.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'assign': 0.04; 'instance,': 0.05; 'reply-to:addr:comp.lang.python': 0.09; 'statement.': 0.09; 'to:addr:comp.lang.python': 0.09; 'c++': 0.12; 'cc:addr:python-list': 0.15; '(besides': 0.16; 'allowed.': 0.16; 'modified.': 0.16; 'subject:copy': 0.16; 'wrote:': 0.16; 'instance': 0.18; 'modified': 0.18; 'cc:no real name:2**0': 0.21; 'discussion': 0.21; 'so.': 0.21; 'header:In-Reply-To:1': 0.22; 'obviously': 0.23; '(where': 0.23; 'object,': 0.24; 'cc:2**0': 0.25; 'performing': 0.25; 'pm,': 0.26; 'expressions': 0.28; 'problem': 0.29; 'cc:addr:python.org': 0.29; 'at.': 0.30; 'semantics': 0.30; 'thanks': 0.32; "can't": 0.32; 'header:User- Agent:1': 0.33; 'from:addr:googlemail.com': 0.34; 'operations': 0.34; 'combination': 0.36; 'two': 0.37; 'reference': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'getting': 0.37; 'received:209.85': 0.38; 'should': 0.38; 'either': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'difference': 0.40; 'design': 0.61; 'your': 0.61; 'free': 0.63; 'behaviors': 0.67; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'stand': 0.72; 'reply-to:addr:googlegroups.com': 0.74; 'different.': 0.84; 'subject:write': 0.84; 'skip:2 50': 0.91 Newsgroups: comp.lang.python Date: Thu, 2 Feb 2012 05:33:17 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.204.77.169; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> User-Agent: G2/1.0 X-Google-Web-Client: true MIME-Version: 1.0 Subject: Re: copy on write From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: comp.lang.python@googlegroups.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328189605 news.xs4all.nl 6881 [2001:888:2000:d::a6]:52639 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19790 =E5=9C=A8 2012=E5=B9=B41=E6=9C=8814=E6=97=A5=E6=98=9F=E6=9C=9F=E5=85=ADUTC+= 8=E4=B8=8A=E5=8D=886=E6=97=B648=E5=88=8629=E7=A7=92=EF=BC=8CEvan Driscoll= =E5=86=99=E9=81=93=EF=BC=9A > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+=3D shall never do so. That's the main > > difference I was getting at. >=20 > I was talking about the combination of + and =3D, since the discussion is= =20 > about 'a =3D a + b' vs 'a +=3D b', not 'a + b' vs 'a +=3D b' (where the= =20 > differences are obvious). >=20 > And I stand by my statement. In 'a =3D a + b', operator+ obviously return= s=20 > a new object, but operator=3D should then go and assign the result to and= =20 > return a reference to 'a', just like how 'a +=3D b' will return a=20 > reference to 'a'. > The operation a+b means add(a,b) and returns a result instance, furthermore= a and b can't be modified. The expression a =3D a+b are two operations not one. But in C or C++ the p= roblem is mixing operations and expressions in a free style allowed. =20 The operation a+=3Db means a modified by b and b can't be changed. Note that no new instance is necessary in a+=3Db. =20 =20 > If you're working in C++ and overload your operators so that 'a +=3D b'= =20 > and 'a =3D a + b' have different observable behaviors (besides perhaps=20 > time), then either your implementation is buggy or your design is very=20 > bad-mannered. >=20 > Evan Do you mean the result instances after 'a+=3Db' and 'a=3Da+b' or=20 the actions of behaviors of instances involved in performing 'a+=3Db' and = 'a=3Da+b'?