Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #11260
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Curious compiler warning |
| Date | 2012-01-11 23:30 -0800 |
| Organization | albasani.net |
| Message-ID | <jem26v$7t2$1@news.albasani.net> (permalink) |
| References | (3 earlier) <jeiu63$es3$1@news.albasani.net> <KUcPq.69975$Dr1.36221@newsfe08.iad> <jek2kn$i1b$1@speranza.aioe.org> <jek824$sqv$1@news.albasani.net> <O7adnV3zzsd9U5DSnZ2dnUVZ_oOdnZ2d@earthlink.com> |
On 01/11/2012 10:03 AM, Patricia Shanahan wrote:
> On 1/11/2012 6:58 AM, Lew wrote:
> ...
>> "Readability" is such a subjective term. Someone who knows C, C++, C#,
>> Java or certain other languages might find 'x[i++] = y[j++]" perfectly
>> readable. Someone not familiar with these programming languages might not.
>
> I am familiar with C and C++. In the case of C, I've led a compiler
> implementation project. I fully understand that expression.
>
> It seems less obvious to me than it would written out as three
> statements. Just as I like methods with a single clear purpose, I prefer
> statements that have a single clear purpose such as "copy an element
> from y to x", or "increment i".
Good point.
>> If your observation that such expressions has any evidence to back it up
>> it's a good argument for something. Maybe not for changing the potency
>> of the auto-inc/decrement operator but for hiring better-trained
>> programmers, but for something. Assuming the evidence sustains the
>> observation.
>>
>> If you have a hard time understanding that expression and you call
>> yourself a Java programmer, there's a disconnect.
>>
>
> Fortunately, I don't care about being a Java programmer, or a C
> programmer, or any other qualified sort of programmer. I'm just a
> programmer. For my purposes, writing simple, obvious code in whatever
> language I happen to be using is far more important than showing off my
> understanding of the JLS.
>
> The JLS itself agrees with me on this: "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]
>
> The block:
> {
> x[i] = y[i];
> i++;
> j++;
> }
>
> follows that recommendation. Squishing all three side effects into one
> statement does not.
>
> I would go against a JLS recommendation about how to use the language
> only if I had a strong positive reason to do so. That is especially the
> case when it is arguing for simplicity, which I would prefer anyway.
Well, they're not so much talking about how to use the language as about
programming style generally, so it's not normative, though it is good advice.
I just don't happen personally to agree that 'stuff[++index]' is all that
difficult to comprehend or all that dangerous to use, but I'm also no opponent
of verbosity in service of clarity. So my question about why the
autodecrement was on a separate line has been fully and usefully answered, and
I encourage everyone to do so.
But if you aren't using the old value, please use the prefix form of the operator.
That autodecrement was used at all in the OP's example is still open to criticism.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Curious compiler warning Novice <novice@example..com> - 2012-01-11 01:51 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 18:10 -0800
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 02:36 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 19:03 -0800
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 07:50 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 23:57 -0800
Re: Curious compiler warning Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-11 05:47 -0400
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 13:25 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 06:58 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 07:01 -0800
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-11 10:03 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 23:30 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:10 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 23:32 -0800
Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 01:44 -0600
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:42 -0800
Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 10:51 -0600
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-12 07:50 -0800
Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 10:54 -0600
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 11:51 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 20:58 -0800
Re: Curious compiler warning "Gavino" <invalid@invalid.invalid> - 2012-01-11 20:05 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:47 -0800
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-21 12:13 -0800
Re: Curious compiler warning Novice <novice@example..com> - 2012-01-11 04:55 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 21:46 -0800
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 07:55 +0000
Re: Curious compiler warning Roedy Green <see_website@mindprod.com.invalid> - 2012-01-11 01:35 -0800
Re: Curious compiler warning "Gavino" <invalid@invalid.invalid> - 2012-01-11 20:05 +0100
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:18 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:55 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 11:59 -0800
Re: Curious compiler warning Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-13 00:02 +0000
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-12 16:11 -0800
Re: Curious compiler warning Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-13 01:31 +0000
Re: Curious compiler warning Roedy Green <see_website@mindprod.com.invalid> - 2012-01-11 18:26 -0800
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-11 19:01 -0800
Re: Curious compiler warning Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-11 23:23 -0500
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:00 -0800
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:50 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:14 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:05 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 12:02 -0800
Re: Curious compiler warning Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-10 21:11 -0500
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 18:17 -0800
Re: Curious compiler warning bugbear <bugbear@trim_papermule.co.uk_trim> - 2012-01-11 16:10 +0000
Re: Curious compiler warning Lars Enderin <lars.enderin@telia.com> - 2012-01-11 20:45 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:09 -0800
Re: Curious compiler warning Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-01-12 18:14 +0200
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning David Lamb <dalamb@cs.queensu.ca> - 2012-01-21 09:12 -0500
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:21 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:08 -0800
Re: Eclipse 3.7.1 compiler warning v_borchert@despammed.com (Volker Borchert) - 2012-01-11 21:10 +0000
csiph-web