[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ast-users] Arithmetic assignment side-effects
From: |
Janis Papanagnou |
Subject: |
RE: [ast-users] Arithmetic assignment side-effects |
Date: |
Tue, 6 Aug 2013 12:49:06 +0200 |
> >
> > 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 language. With LVALUE=RVALUE and
LVALUE+=LVALUE, where the result is an LVALUE, consider it evaluated as
("ref"(x) = deref(x)+deref(x)) = 1
(Try your expression above in C++, for example. It works as expected.)
Nonetheless right to left parsing seems the only sensible semantics in
case of = and op= assignments.
Janis
>
[...]
>
> 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
> _______________________________________________
> ast-users mailing list
> ast-users@lists.research.att.com
> http://lists.research.att.com/mailman/listinfo/ast-users
- Re: Arithmetic assignment side-effects, (continued)
- 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, 2013/08/06
- Re: Arithmetic assignment side-effects, Andreas Schwab, 2013/08/06
- RE: [ast-users] Arithmetic assignment side-effects,
Janis Papanagnou <=
- 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