Re: Arithmetic assignment side-effects

2013-08-04 Thread Linda Walsh
Dan Douglas wrote: On Sunday, August 04, 2013 06:08:18 PM Linda Walsh wrote: 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. = and += have equal precedence. Associativi

Re: Arithmetic assignment side-effects

2013-08-04 Thread Dan Douglas
On Sunday, August 04, 2013 06:08:18 PM Linda Walsh wrote: > 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. = and += have equal precedence. Associativity is right to left

Re: Arithmetic assignment side-effects

2013-08-04 Thread Linda Walsh
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 a

Re: Arithmetic assignment side-effects

2013-08-04 Thread Chris Down
On 2013-08-04 22:41, Andreas Schwab wrote: > x+=a is the same as x=x+a. In most cases I'd agree, in this case I think it changes the logic when considering += as an atomic increment (which, of course, += isn't, but aesthetically it presents itself as such) as opposed to two separate operations. >

Re: Arithmetic assignment side-effects

2013-08-04 Thread Andreas Schwab
Chris Down writes: > On 2013-08-03 17:04, Dan Douglas wrote: >> Is it specified what the value of x should be after this expression? >> >> x=0; : $((x+=x=1)) > > I don't know if it is specified in a standard (I suspect it may be undefined), > but it looks pretty clear to me that the answer should

Re: Arithmetic assignment side-effects

2013-08-04 Thread Chris Down
On 2013-08-03 17:04, Dan Douglas wrote: > Is it specified what the value of x should be after this expression? > > x=0; : $((x+=x=1)) I don't know if it is specified in a standard (I suspect it may be undefined), but it looks pretty clear to me that the answer should be 2. Has anyone proposed logi