I’ve just discovered a subtlety in teletype’s operator precedence or parse order. At the > prompt, do
P.PUSH 10
P.PUSH 13
Now
P 0
returns 10, and
P 1
returns 13. However,
ADD P 0 P 1
returns zero instead of 23, and
P 0
now returns 13! What I think is happening here is that P 0 P 1 is getting evaluated before the ADD, so P 0 is getting set to the value of P 1; what surprises me is that ADD doesn’t insist on having two arguments and fails silently by returning zero. I know that data flows from right to left, but I would have thought the parser would vet the whole line before performing any evaluations.
(Although
X P 0
Y P 1
ADD X Y
is a fine workaround for this, both lines and variables are precious in teletype, so I was trying for concision.)