Re: No ||= operator in Java?

Discussion in 'Java' started by Lothar Kimmeringer, Jul 27, 2003.

  1. On 27 Jul 2003 09:36:20 GMT, Joona I Palaste wrote:

    > Isn't there a ||= operator in Java? The expression "a ||= b" would mean
    > the same as "a = a || b" except that a was only evaluated once.
    > The same would apply for the &&= operator. Isn't there a &&= operator in
    > Java either?


    What's wrong with |= and &=?


    Regards, Lothar
    --
    Lothar Kimmeringer E-Mail:
    PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

    Always remember: The answer is forty-two, there can only be wrong
    questions!
     
    Lothar Kimmeringer, Jul 27, 2003
    #1
    1. Advertising

  2. Lothar Kimmeringer <> scribbled the following:
    > On 27 Jul 2003 09:36:20 GMT, Joona I Palaste wrote:
    >> Isn't there a ||= operator in Java? The expression "a ||= b" would mean
    >> the same as "a = a || b" except that a was only evaluated once.
    >> The same would apply for the &&= operator. Isn't there a &&= operator in
    >> Java either?


    > What's wrong with |= and &=?


    The fact that they work on integers, not on booleans, for example?

    --
    /-- Joona Palaste () ---------------------------\
    | Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
    | http://www.helsinki.fi/~palaste W++ B OP+ |
    \----------------------------------------- Finland rules! ------------/
    "'So called' means: 'There is a long explanation for this, but I have no
    time to explain it here.'"
    - JIPsoft
     
    Joona I Palaste, Jul 27, 2003
    #2
    1. Advertising

  3. Lothar Kimmeringer

    Tim Tyler Guest

    Lothar Kimmeringer <> scribbled the following:

    > What's wrong with |= and &=?


    They unnecessarily evaluate the RHS when it is not necessary to do so.

    If | and & were always the best thing to use, then the existence of
    && and || needs explanation.

    ||= and &&= would also give better type safety in some respects.
    --
    __________
    |im |yler http://timtyler.org/
     
    Tim Tyler, Jul 27, 2003
    #3
  4. Lothar Kimmeringer

    Adam Maass Guest

    "Lothar Kimmeringer" <> wrote:
    > On 27 Jul 2003 09:36:20 GMT, Joona I Palaste wrote:
    >
    > > Isn't there a ||= operator in Java? The expression "a ||= b" would mean
    > > the same as "a = a || b" except that a was only evaluated once.
    > > The same would apply for the &&= operator. Isn't there a &&= operator in
    > > Java either?

    >
    > What's wrong with |= and &=?


    I personally saw what appeared to be a VM bug -- four years ago, now -- in
    code written with the boolean version of |= . A 1.2 VM from Sun operating
    on Solaris.

    Enough reason for me to avoid boolean |= .

    -- Adam Maass
     
    Adam Maass, Jul 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jakob Bieling

    Q: operator void* or operator bool?

    Jakob Bieling, Mar 5, 2004, in forum: C++
    Replies:
    2
    Views:
    587
    Rob Williscroft
    Mar 5, 2004
  2. John Smith
    Replies:
    2
    Views:
    423
    Ivan Vecerina
    Oct 6, 2004
  3. Alex Vinokur
    Replies:
    4
    Views:
    3,053
    Peter Koch Larsen
    Nov 26, 2004
  4. Alex Vinokur
    Replies:
    3
    Views:
    5,030
    Jeff Schwab
    Mar 20, 2005
  5. Tim Clacy
    Replies:
    15
    Views:
    2,689
    Kanenas
    May 30, 2005
Loading...

Share This Page