- ABORT
- ABORT"
- ABS
- ACCEPT
- ACTION-OF
- AGAIN
- ALIGN
- ALIGNED
- ALLOT
- AND
- BASE
- BEGIN
- BL
- BUFFER:
- [
- [CHAR]
- [COMPILE]
- [']
- CASE
- C,
- CELL+
- CELLS
- C@
- CHAR
- CHAR+
- CHARS
- COMPILE,
- CONSTANT
- COUNT
- CR
- CREATE
- C!
- :
- :NONAME
- ,
- C"
- DECIMAL
- DEFER
- DEFER@
- DEFER!
- DEPTH
- DO
- DOES>
- DROP
- DUP
- /
- /MOD
- .R
- .(
- ."
- ELSE
- EMIT
- ENDCASE
- ENDOF
- ENVIRONMENT?
- ERASE
- EVALUATE
- EXECUTE
- EXIT
- =
- FALSE
- FILL
- FIND
- FM/MOD
- @
- HERE
- HEX
- HOLD
- HOLDS
- I
- IF
- IMMEDIATE
- INVERT
- IS
- J
- KEY
- LEAVE
- LITERAL
- LOOP
- LSHIFT
- MARKER
- MAX
- MIN
- MOD
- MOVE
- M*
- -
- NEGATE
- NIP
- OF
- OR
- OVER
- 1-
- 1+
- PAD
- PARSE-NAME
- PARSE
- PICK
- POSTPONE
- +
- +LOOP
- +!
- QUIT
- RECURSE
- REFILL
- REPEAT
- RESTORE-INPUT
- R@
- ROLL
- ROT
- RSHIFT
- R>
- SAVE-INPUT
- SIGN
- SM/REM
- SOURCE-ID
- SOURCE
- SPACE
- SPACES
- STATE
- SWAP
- ;
- S\"
- S"
- S>D
- !
- THEN
- TO
- TRUE
- TUCK
- TYPE
- '
- *
- */
- */MOD
- 2DROP
- 2DUP
- 2/
- 2@
- 2OVER
- 2R@
- 2R>
- 2SWAP
- 2!
- 2*
- 2>R
- U.R
- UM/MOD
- UM*
- UNLOOP
- UNTIL
- UNUSED
- U.
- U<
- U>
- VALUE
- VARIABLE
- WHILE
- WITHIN
- WORD
- XOR
- 0=
- 0<
- 0>
- 0<>
- \
- .
- <
- >
- <>
- #>
- <#
- #
- #S
- (
- ?DO
- ?DUP
- >BODY
- >IN
- >NUMBER
- >R
6.2.0340 2>R two-to-r CORE EXT
Interpretation:
Execution:
Transfer cell pair x1 x2 to the return stack. Semantically equivalent to SWAP >R >R.
See:
Rationale:
ContributeContributions
EricBlake
[395] Suggested implementationsSuggested reference implementation2025-08-04 15:28:09
I can see that tests for 2>R were not added until version 0.10 of the testsuite (Aug 2014), which post-dates Forth-2012 and thus explains why those tests are not visible in Annex F. Had I seen that test sooner, I would have caught the bug in my initial attempted implementation. Namely:
: 2>R SWAP >R >R ; \ buggy implementation
appears to be a straightforward transcription of the normative requirement on semantics, except that it has the problem of not being immediate, and thus falls foul of the ambiguous behavior when using >r within a word that is not matched by r> in the same word. A simple fix is to make things immediate (so that all manipulations of the return stack are being done in the context of the code being compiled, rather than in the body of a helper word that may have pushed a nest-sys to the return stack), so it could be wise to list this as a reference implementation:
: 2>R ( x1 x2 -- ) ( R: -- x1 x2 )
POSTPONE SWAP POSTPONE >R POSTPONE >R
; IMMEDIATE
and similarly for 2R@ and 2R>. Or, if you take the approach of the reference implementation of NR> which includes a disclaimer that it has an environmental dependency on the system placing exactly one cell on the return stack for nest-sys (we already document that reference examples need not be universal):
: 2>R ( x1 x2 -- ) ( R: -- x1 x2 )
\ This reference implementation has an environmental dependency on being able to safely stash a one-cell nest-sys containing the return back to the caller
SWAP R> SWAP >R SWAP >R >R ;