[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic assignment side-effects
From: |
Dan Douglas |
Subject: |
Re: Arithmetic assignment side-effects |
Date: |
Tue, 06 Aug 2013 04:21:24 -0500 |
User-agent: |
KMail/4.10.5 (Linux/3.10.1-pf+; KDE/4.10.5; x86_64; ; ) |
On Tuesday, August 06, 2013 09:20:38 AM Andreas Schwab wrote:
> DJ Mills <address@hidden> 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 an absolute prerequisite to evaluating the assignment
itself. (x += x) = 1 is nonsense. It evaluates to 0 = 1.
We know that the shell doesn't simply flatten the expression in the case of
indirection.
y='1 +'; ((x = y 1))
is invalid. Therefore it must evaluate full expressions as it references them.
If you have
x=0 y=x+=x let y=1
and try to evaluate y first, y evaluates to x+=x which evaluates to 0 and the
overall expression is invalid again.
I've also already proven that at least in ksh it goes right to left, because
if you define a setter property to trigger a side-effect for each variable,
the RHS fires before the LHS of the +=.
There's just no amount of mind-bending I can think of that could make
evaluating the += first produce anything other than an error.
--
Dan Douglas
- Re: Arithmetic assignment side-effects, (continued)
- Re: Arithmetic assignment side-effects, Chris Down, 2013/08/04
- Re: Arithmetic assignment side-effects, Andreas Schwab, 2013/08/04
- Re: Arithmetic assignment side-effects, Chris Down, 2013/08/04
- Re: Arithmetic assignment side-effects, Linda Walsh, 2013/08/04
- Re: Arithmetic assignment side-effects, Dan Douglas, 2013/08/05
- Re: Arithmetic assignment side-effects, Linda Walsh, 2013/08/05
- Re: Arithmetic assignment side-effects, Andreas Schwab, 2013/08/05
- Re: Arithmetic assignment side-effects, DJ Mills, 2013/08/05
- 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 <=
- 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
- Re: [ast-users] Arithmetic assignment side-effects, Chet Ramey, 2013/08/06
- Re: Arithmetic assignment side-effects, DJ Mills, 2013/08/06
- Re: Arithmetic assignment side-effects, Chet Ramey, 2013/08/06