apldyalog

Why does output of modified assignment return the value on the right and not the value of the variable?


      a
0
      a×←5
      a
0
      (a×←5)
5
      a
0
      (⎕←a×←5)
5
5

Why does having braces(or a ⎕←) over a modified assignment change the result but the variable is set correctly. I am not able to wrap my head around what is going on here. Should this have the result of the assignment ie. the value of the variable as the output?


Solution

  • As per the documentation, the result of an assignment (the “pass-through” value) is whatever is on the right of the — no exceptions. So a×←5 is 5, not 0. The parentheses or ⎕← just coerce the otherwise shy value to be visibly returned.