Question

What should the stack comments look like when the return stack comes into play?

: FOO  ( d2 d1 tos -- sum flag ) 
   ... ;

This word expects 5 cells and returns 2 cells, but what goes between the parentheses when the return stack is used? e.g. how would the stack comment look for this:

: BAZ  ( d2 d1 tos -- d )
   BASE @ >R >R   ( d2 d1 )
   2SWAP D-   ( d ) 
   R> DUP
   R@ BAR
   R> BONK ;
Was it helpful?

Solution

The return stack effect is noted separately and prefixed with R:.

See dpANS Forth 2.2.2. As an example, the description of >R: "Execution: ( x -- ) ( R: -- x )"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top