chitselb
chitselb

Reputation: 153

Forth stack comments with return stack

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 ;

Upvotes: 4

Views: 447

Answers (1)

Lars Brinkhoff
Lars Brinkhoff

Reputation: 14325

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

Upvotes: 6

Related Questions