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


Groups > comp.lang.java.programmer > #19456

Re: Assigning void

From "Peter J. Holzer" <hjp-usenet2@hjp.at>
Newsgroups comp.lang.java.programmer
Subject Re: Assigning void
Date 2012-10-21 13:24 +0200
Organization LUGA
Message-ID <slrnk87mr1.im0.hjp-usenet2@hrunkner.hjp.at> (permalink)
References (5 earlier) <mn.6aec7dcaffbb07c0.70216@a.com> <k5cg71$6j7$1@dont-email.me> <mn.6b2b7dca897be4d2.70216@a.com> <1gsagb5e23bgw.1v1kss3azi0d7$.dlg@40tude.net> <jo5jb4i4wtuh$.h5g0v7ha9x0m$.dlg@40tude.net>

Show all headers | View raw


On 2012-10-20 16:56, Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> wrote:
> On Sat, 20 Oct 2012 18:00:23 +0200, Joerg Meier wrote:
>> On Sat, 13 Oct 2012 13:31:58 -0700, Wojtek wrote:
>>> int compare = (a > b) ? 1 : (a < b) ? -1 : 0;
>> 
>> I know it's been a few days, but I just read this and wanted to add that I
>> find the above expression pretty horrible, as I could not without
>> experimentation or study of the JLS tell how that would turn out - could be
>> either
>> 
>> int compare = ((a > b) ? 1 : (a < b)) ? -1 : 0;
>
> It can't be that one.  That expression doesn't compile, because the literal
> "1" is not a boolean value, nor is "(a < b)" an integer value, and so "1 :
> (a < b)" is not a valid portion of a ?: operator expression (i.e. the two
> possible results don't match in type, nor are convertible to each other's
> type).

True. However, in C there is (was) no boolean type so the precedence
could still be the wrong way around (requiring extra parentheses in
Java).

However, the inventors in C did spend some time contemplating typical
uses before deciding on the precedence of the operators, and they
expected that nesting ?: like this:

    cond1 ? value1 :
    cond2 ? value2 :
    cond3 ? value3 :
            value4

would be a typical use and chose the precedence and associativity to
allow this without extra parentheses.

	hp


-- 
   _  | Peter J. Holzer    | Deprecating human carelessness and
|_|_) | Sysadmin WSR       | ignorance has no successful track record.
| |   | hjp@hjp.at         | 
__/   | http://www.hjp.at/ |  -- Bill Code on asrg@irtf.org

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


Thread

Assigning void Wojtek <nowhere@a.com> - 2012-10-12 22:54 -0700
  Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-12 23:27 -0700
    Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-13 12:35 -0700
  Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-13 09:26 -0400
  Re: Assigning void Donkey Hottie <donkey@fredriksson.dy.fi> - 2012-10-13 17:06 +0300
    Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 10:34 -0400
    Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-13 22:33 +0200
      Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 17:34 -0400
      Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-13 17:45 -0400
        Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-13 21:35 -0400
        Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-16 00:16 +0200
  Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 11:59 -0400
    Re: Assigning void glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-10-13 17:05 +0000
      Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 14:26 -0400
        Re: Assigning void markspace <-@.> - 2012-10-13 11:51 -0700
          Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 15:08 -0400
          Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-13 12:28 -0700
            Re: Assigning void markspace <-@.> - 2012-10-13 12:42 -0700
              Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 12:54 -0700
                OT - Trolling Wojtek <nowhere@a.com> - 2012-10-13 14:16 -0700
                Re: OT - Trolling Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 18:09 -0400
                Re: OT - Trolling Gene Wirchenko <genew@ocis.net> - 2012-10-14 18:47 -0700
              Re: Assigning void Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-13 20:28 +0000
              Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-13 13:31 -0700
                Re: Assigning void Joerg Meier <joergmmeier@arcor.de> - 2012-10-20 18:00 +0200
                Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-20 09:56 -0700
                Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-21 13:24 +0200
                Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-21 10:23 -0700
                Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 00:13 +0200
                Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-21 16:25 -0700
                Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 08:43 +0200
                Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 10:18 +0200
                Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-22 08:14 -0700
                Re: Assigning void glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-10-21 19:45 +0000
                Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 00:14 +0200
            Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 12:44 -0700
              Re: Assigning void Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-10-15 14:38 +0300
                Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-15 09:11 -0700
        Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 15:03 -0400
          Re: Assigning void glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-10-13 20:21 +0000
    Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 12:38 -0700
      Re: Assigning void markspace <-@.> - 2012-10-13 12:49 -0700
        Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 13:03 -0700
          Re: Assigning void Robert Klemme <shortcutter@googlemail.com> - 2012-10-14 14:09 +0200
            Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-14 11:31 -0700
      Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 19:55 -0400
        Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 20:25 -0400
          Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 21:01 -0400
            Re: Assigning void Gene Wirchenko <genew@ocis.net> - 2012-10-14 18:42 -0700
  Re: Assigning void Roedy Green <see_website@mindprod.com.invalid> - 2012-10-14 00:51 -0700
  Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-14 10:40 -0400
  Re: Assigning void Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-21 01:24 +0200
    Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-21 14:52 -0700
      Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-21 20:13 -0400
        Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-21 20:20 -0700
          Re: Assigning void Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-22 11:12 +0200
        Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-24 22:03 +0200
          Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-24 17:47 -0400
            Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-25 01:02 +0200
              Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-24 20:21 -0400
                Re: Assigning void Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-25 20:04 +0000
                (OT) Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-25 16:31 -0400
                Re: (OT) Re: Assigning void Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-25 20:44 +0000
            Re: Assigning void Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-10-25 07:25 -0300
              Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-25 11:12 -0700
      Re: Assigning void Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-22 11:01 +0200
      Re: Assigning void Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-10-23 00:38 +0200

csiph-web