What does left-to-right associativity mean?

后端 未结 6 729
生来不讨喜
生来不讨喜 2020-12-29 21:23

I am confused about the definition of left-to-right and right-to-left associativity. I have also seen them called left associativity and right associativity and would like t

6条回答
  •  长情又很酷
    2020-12-29 22:16

    You can see that from the following words:

    When we combine operators to form expressions, the order in which the operators are to be applied may not be obvious. For example, a + b + c can be interpreted as ((a + b) + c) or as (a + (b + c)). We say that + is left-associative if operands are grouped left to right as in ((a + b) + c). We say it is right-associative if it groups operands in the opposite direction, as in (a + (b + c)).

    A.V. Aho & J.D. Ullman 1977, p. 47

提交回复
热议问题