Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Re: Looking for good table with all Java operators (http://www.velocityreviews.com/forums/t712900-re-looking-for-good-table-with-all-java-operators.html)

Lew 01-26-2010 02:11 AM

Re: Looking for good table with all Java operators
 
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 01-26-2010 01:39 PM

Re: Looking for good table with all Java operators
 
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

Tom Anderson 01-26-2010 06:17 PM

Re: Looking for good table with all Java operators
 
On Tue, 26 Jan 2010, Thomas Pornin wrote:

> According to Lew <noone@lewscanon.com>:
>> 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


All times are GMT. The time now is 07:06 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.