[rrd-developers] ROL and ROR for RPN

Tobias Oetiker tobi at oetiker.ch
Tue May 6 09:29:04 CEST 2014

Hi Steve,

I like the patch ... would you make it into a pull request on
github (vs the master branch) and include the appropriate
documentation changes ...


Today Steve Shipway wrote:

> So, I have a patch (unified context diff) to add the RPN operators ROLL,
> DEPTH: push the number of stack elements onto the stack
>   1,2,3,DEPTH ==> 1,2,3,3
> COPY: pop the top value form the stack.  Copy that number of elements on the
> stack.  So, DUP is the same as 1,COPY
>    1,2,3,2,COPY ==>  1,2,3,2,3
> INDEX: identify the item that far down the stack and copy it onto the top of
> the stack (1-based). So, DUP is the same as 1,INDEX
>  1,2,3,4,5,2,INDEX ==> 1,2,3,4,5,4
> ROLL: rotate the top n items by s steps (can be positive or negative) So
> EXCH is the same as 2,1,ROLL or 2,-1,ROLL
>  1,2,3,4,5,3,-1,ROLL ==> 1,2,4,5,3
> This should allow much more extensive stack manipulation.  Stack underflow
> and overflow are handled.
> Thanks for the feedback from the group on making ROLL more generic, and
> adding DEPTH, INDEX and COPY.  These functions may benefit from more
> extensive testing as properly debugging the RPN engine is awkward.  More
> feedback always welcome.
> Steve
> Steve Shipway
> s.shipway at auckland.ac.nz

Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
www.oetiker.ch tobi at oetiker.ch +41 62 775 9902

More information about the rrd-developers mailing list