Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.help Subject: Re: Why would one use += 1 at the place of ++? Date: Thu, 19 May 2011 07:51:43 -0400 Organization: A noiseless patient Spider Lines: 19 Message-ID: References: <8762p7upgn.fsf@merciadriluca-station.MERCIADRILUCA> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 19 May 2011 11:52:17 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="BrOwaJANne849xlH+KPYjQ"; logging-data="16169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+V34EoT7bNavv90hVJBU0O" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: <8762p7upgn.fsf@merciadriluca-station.MERCIADRILUCA> Cancel-Lock: sha1:6LVVgIzoJeviv6y0oFebznIvnc4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:692 On 5/19/2011 3:19 AM, Merciadri Luca wrote: > > I've heard that it is generally better to use += 1 at the place of ++. For me, > they do exactly the same thing, maybe except that the former is > actually splitted into different atomic operations, when the latter > might be done in an atomic operation? `x += 1' has the same meaning as `++x'. If the value of the expression is not used, it is also equivalent to `x++'. I can think of no important reason to prefer one of the first two over the other, and cannot imagine why anyone would call either "generally better." If the value is not used, I'd also lump the third in with the first two and choose whichever seems more readable in context. None of the three is an atomic operation. -- Eric Sosman esosman@ieee-dot-org.invalid