[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic assignment side-effects
From: |
Linda Walsh |
Subject: |
Re: Arithmetic assignment side-effects |
Date: |
Sun, 04 Aug 2013 18:08:18 -0700 |
User-agent: |
Thunderbird |
Chris Down wrote:
Yes, I agree, it becomes ambiguous when described in this fashion. I think the
aesthetics of x+=y vs x=x+y are important here.
From the bash manpage, it would see that += is higher precedence
than assignment, so the increment would be done first, followed
by the attempt at an assignment of 1 to 1.
(Which might be determined as 'true', = 1 in (()) expressions...
so -- only in looking at the manpage, I'd have to lean toward '1'.
(I had been leaning toward 2 since the ='s are evaled from the right, but
the += is done first according to this:
The operators and their precedence, associativity, and values are the
same as in the C language. The following list of operators is grouped
into levels of equal-precedence operators. The levels are listed in
order of decreasing precedence.
id++ id--
variable post-increment and post-decrement
++id --id
variable pre-increment and pre-decrement
- + unary minus and plus
! ~ logical and bitwise negation
** exponentiation
* / % multiplication, division, remainder
+ - addition, subtraction
<< >> left and right bitwise shifts
<= >= < >
comparison
== != equality and inequality
& bitwise AND
^ bitwise exclusive OR
| bitwise OR
&& logical AND
|| logical OR
expr?expr:expr
conditional operator
= *= /= %= += -= <<= >>= &= ^= |=
assignment
expr1 , expr2
comma
- Arithmetic assignment side-effects, Dan Douglas, 2013/08/03
- Re: Arithmetic assignment side-effects, DJ Mills, 2013/08/05
- Re: Arithmetic assignment side-effects, Andreas Schwab, 2013/08/06
- Re: Arithmetic assignment side-effects, Dan Douglas, 2013/08/06
- Re: Arithmetic assignment side-effects, Andreas Schwab, 2013/08/06
- RE: [ast-users] Arithmetic assignment side-effects, Janis Papanagnou, 2013/08/06
- Re: [ast-users] Arithmetic assignment side-effects, Chet Ramey, 2013/08/06