mikaelpatel / Arduino-Shell

RPN Postscript/Forth Command Shell for Arduino
19 stars 5 forks source link

Question: Stack markers #19

Closed dpharris closed 8 years ago

dpharris commented 8 years ago

I am not sure I fully understand stack markers []. [6 34$I] would read 6 bytes from I2C device 34, and leaves 6 items on the stack with a count 6 on top, useful for future processing.

How does that differ from just: 6 34 $I 6 ? I will go and reread PS (last time 25 yrs ago!).

mikaelpatel commented 8 years ago

No difference at all until you start using functions with variable number of parameters or return values.

mikaelpatel commented 8 years ago

PS syntax for array is [...]. Behind this is the functions mark, counttomark and allocation of the array. I have "used" [ as mark, and ] as counttomark. A simplification for stack based vectors (and with the new stack direction, from top stack to bottom in memory).