Re: [ast-users] Arithmetic assignment side-effects

2013-08-06 Thread Chet Ramey
On 8/6/13 6:49 AM, Janis Papanagnou wrote: > Nonetheless right to left parsing seems the only sensible semantics in > case of = and op= assignments. Ummm...why is that? Unless you mean evaluating the RHS first, without Andreas's implicit conversion from x+=a to x=x+a? Chet -- ``The lyf so sho

Re: [ast-users] Arithmetic assignment side-effects

2013-08-06 Thread Chet Ramey
On 8/6/13 5:21 AM, Dan Douglas wrote: > On Tuesday, August 06, 2013 09:20:38 AM Andreas Schwab wrote: >> DJ Mills writes: >> >>> I still don't see that; >> >> Go strictly from left to right. > > How do you assign something that hasn't been evaluated yet? Evaluating the > expression on the RHS is

RE: [ast-users] Arithmetic assignment side-effects

2013-08-06 Thread Janis Papanagnou
> > > > Go strictly from left to right. > > How do you assign something that hasn't been evaluated yet? Evaluating the > expression on the RHS is an absolute prerequisite to evaluating the > assignment > itself. (x += x) = 1 is nonsense. It evaluates to 0 = 1. It makes sense, depending on the

Re: [ast-users] Arithmetic assignment side-effects

2013-08-05 Thread Roland Mainz
On Sun, Aug 4, 2013 at 12:30 AM, Roland Mainz wrote: > On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas wrote: >> Is it specified what the value of x should be after this expression? >> >> x=0; : $((x+=x=1)) >> >> Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gcc both >> throw wa

Re: [ast-users] Arithmetic assignment side-effects

2013-08-03 Thread Roland Mainz
On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas wrote: > Is it specified what the value of x should be after this expression? > > x=0; : $((x+=x=1)) > > Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gcc both > throw warnings about it, but both plus icc agree on 2. Just curious:

RE: [ast-users] Arithmetic assignment side-effects

2013-08-03 Thread Janis Papanagnou
> > Is it specified what the value of x should be after this expression? Typically assignment cascades (including the op= variants) are evaluated from right to left... > > x=0; : $((x+=x=1)) ...so this would produce 2. > > Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gc

Re: [ast-users] Arithmetic assignment side-effects

2013-08-03 Thread Roland Mainz
On Sun, Aug 4, 2013 at 12:41 AM, Dan Douglas wrote: > On Sunday, August 04, 2013 12:30:48 AM Roland Mainz wrote: >> On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas wrote: >> > Is it specified what the value of x should be after this expression? >> > >> > x=0; : $((x+=x=1)) >> > >> > Bash, ksh93, mks

Re: [ast-users] Arithmetic assignment side-effects

2013-08-03 Thread Dan Douglas
On Sunday, August 04, 2013 12:30:48 AM Roland Mainz wrote: > On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas wrote: > > Is it specified what the value of x should be after this expression? > > > > x=0; : $((x+=x=1)) > > > > Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gcc > > b