Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #707

Re: [OT] Re: Why would one use += 1 at the place of ++?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Fri, 20 May 2011 14:55:55 -0500
Date Fri, 20 May 2011 12:55:53 -0700
From Patricia Shanahan <pats@acm.org>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10
MIME-Version 1.0
Newsgroups comp.lang.java.help
Subject Re: [OT] Re: Why would one use += 1 at the place of ++?
References <8762p7upgn.fsf@merciadriluca-station.MERCIADRILUCA> <4t6Bp.534$pi2.511@newsfe11.iad> <ir30ui$jok$1@dont-email.me> <veSdnZd_-OsAt0jQnZ2dnUVZ_oudnZ2d@earthlink.com> <ir4lca$6dk$1@dont-email.me>
In-Reply-To <ir4lca$6dk$1@dont-email.me>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Message-ID <nYWdnV55_pvWWkvQnZ2dnUVZ_hOdnZ2d@earthlink.com> (permalink)
Lines 30
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 75.8.126.96
X-Trace sv3-bfxjS+1xwFUWN3MDXA+0ZQ6ADDFtf5sjlPqrFZEPQrm9lU0j4g6rJ00x57QXWBHE6Xj2qP1Cg2b9rcc!GPg1Wg5QRZWAZDm/4CsLPxHwlcVyi3a0Y59jDp2IXVoea5SSbwQz482vvWQ0jxVddQeLbxTcGYB4!SmN79v178DFE8+UDGRITB+ilhM2r+KhcIdw9I8/JIxo=
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 2635
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:707

Show key headers only | View raw


On 5/19/2011 7:57 PM, Eric Sosman wrote:
> On 5/19/2011 10:35 AM, Patricia Shanahan wrote:
...
>> I do not understand why those operators exist in Java. They cannot be
>> used without going against style advice in the JLS and Java is not a
>> terse language.
>
> Not sure what style advice you refer to; the word "style" doesn't
> appear in the JLS' index. As for using the operators, I personally
> think they're convenient and easy to read in some contexts where the
> spelled-out counterparts would look clunky, mostly when I'm sliding
> through an array advancing an index as I go: `x[i++]' would be clumsy
> to rewrite with `+='.
...

The recommendation I meant is in Section 15.7, "Evaluation Order":

"It is recommended that code not rely crucially on this specification.
Code is usually clearer when each expression contains at most one side
effect, as its outermost operation, and when code does not depend on
exactly which exception arises as a consequence of the left-to-right
evaluation of expressions."

[http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.7]

Using ++, --, += etc. at the top level of an expression without other
side effects does conform to the recommendation, and that is how I
generally use them.

Patricia

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Why would one use += 1 at the place of ++? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-05-19 09:19 +0200
  Re: Why would one use += 1 at the place of ++? Bent C Dalager <bcd@pvv.ntnu.no> - 2011-05-19 10:22 +0000
  Re: Why would one use += 1 at the place of ++? David Lamb <dalamb@cs.queensu.ca> - 2011-05-19 06:40 -0400
    Re: Why would one use += 1 at the place of ++? Jeff Higgins <jeff@invalid.invalid> - 2011-05-19 07:58 -0400
    [OT] Re: Why would one use += 1 at the place of ++? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-19 08:03 -0400
      Re: [OT] Re: Why would one use += 1 at the place of ++? Patricia Shanahan <pats@acm.org> - 2011-05-19 07:35 -0700
        Re: [OT] Re: Why would one use += 1 at the place of ++? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-19 22:57 -0400
          Re: [OT] Re: Why would one use += 1 at the place of ++? rossum <rossum48@coldmail.com> - 2011-05-20 11:00 +0100
          Re: [OT] Re: Why would one use += 1 at the place of ++? Patricia Shanahan <pats@acm.org> - 2011-05-20 12:55 -0700
      Re: [OT] Re: Why would one use += 1 at the place of ++? David Lamb <dalamb@cs.queensu.ca> - 2011-05-19 17:58 -0400
        Re: [OT] Re: Why would one use += 1 at the place of ++? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-19 23:13 -0400
    Re: Why would one use += 1 at the place of ++? Lew <noone@lewscanon.com> - 2011-05-19 08:43 -0400
  Re: Why would one use += 1 at the place of ++? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-19 07:51 -0400
  Re: Why would one use += 1 at the place of ++? Jeff Higgins <jeff@invalid.invalid> - 2011-05-19 08:03 -0400
    Re: Why would one use += 1 at the place of ++? Lew <noone@lewscanon.com> - 2011-05-19 08:08 -0400
  Re: Why would one use += 1 at the place of ++? Roedy Green <see_website@mindprod.com.invalid> - 2011-05-19 10:23 -0700
    Re: Why would one use += 1 at the place of ++? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-05-19 21:15 +0200
      Re: Why would one use += 1 at the place of ++? Lew <noone@lewscanon.com> - 2011-05-19 15:29 -0400

csiph-web