Re: Looking for good table with all Java operators

Discussion in 'Java' started by Lew, Jan 26, 2010.

  1. Lew

    Lew Guest

    Robbo wrote:
    > Level Category Operator Associativity
    > ---------------------------------------------------------------
    > 1 postfix expr++ expr-- left


    As I was corrected upthread (perhaps you missed that post), there is no
    associativity for postfix operators.

    --
    Lew
    Lew, Jan 26, 2010
    #1
    1. Advertising

  2. Lew

    Lew Guest

    Please attribute quotations.
    Lew wrote:
    >> As I was corrected upthread (perhaps you missed that post), there is no
    >> associativity for postfix operators.


    Robbo wrote:
    > Ok. Thx.
    >
    >
    > Level Category Operator Associativity
    > ---------------------------------------------------------------
    > 1 postfix expr++ expr-- +
    > ---------------------------------------------------------------
    > 2 prefix ++expr --expr right+


    The same reasoning applies to prefix auto{in,de}crement.

    It's been pointed out before, although to be fair, to reach the conclusion it
    would have required thinking about what Patricia posted.
    > ++(a--) and (++a)-- both apply an operator
    > requiring a variable to a non-variable value.


    There's no point talking about associativity of prefix ++ if ++++x is an
    illegal expression. (Or if it means that unary + is applied twice to ++x - I
    didn't try it. Why don't you? It'll be a fun experiment.)

    Thinking about things is a fundamental tool in the programmer's toolbox.

    --
    Lew
    Lew, Jan 26, 2010
    #2
    1. Advertising

  3. Lew

    Tom Anderson Guest

    On Tue, 26 Jan 2010, Thomas Pornin wrote:

    > According to Lew <>:
    >> There's no point talking about associativity of prefix ++ if ++++x is an
    >> illegal expression.

    >
    > There is no "associativity" at all for unary operators. Associativity is
    > a notion which is defined only for binary operators.


    True. The equivalent for unary operators is probably distributivity, or
    whatever it's called. Like how -(a+b) == (-a)+(-b). Although of course
    -(a*b) != (-a)*(-b), so it's a bit more complicated. And not at all
    related to drawing up tables of operators.

    tom

    --
    hypnopomp rapist
    Tom Anderson, Jan 26, 2010
    #3
    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. Frank Ratzlow
    Replies:
    3
    Views:
    1,669
    Frank Ratzlow
    Aug 1, 2003
  2. JPR105
    Replies:
    0
    Views:
    377
    JPR105
    Jan 24, 2004
  3. Yoav
    Replies:
    2
    Views:
    371
    Roedy Green
    Apr 25, 2004
  4. mike3
    Replies:
    5
    Views:
    308
    James Kanze
    May 27, 2007
  5. John B. Matthews
    Replies:
    17
    Views:
    764
    Eric Sosman
    Jan 26, 2010
Loading...

Share This Page