Pregunta

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 ;
¿Fue útil?

Solución

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 )"

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top