15.6.2.1015
CS-PICK
c-s-pick
TOOLS EXT
Interpretation:
Interpretation semantics for this word are undefined.

Execution:
( C: destu ... orig0 | dest0 -- destu ... orig0 | dest0 destu ) ( S: u -- )

Remove u. Copy destu to the top of the control-flow stack. An ambiguous condition exists if there are less than u+1 items, each of which shall be an orig or dest, on the control-flow stack before CS-PICK is executed.

If the control-flow stack is implemented using the data stack, u shall be the topmost item on the data stack.

Rationale:
The intent is to copy a dest on the control-flow stack so that it can be resolved more than once. For example:
\ Conditionally transfer control to beginning of
\ loop. This is similar in spirit to C's "continue"
\ statement.

: ?REPEAT ( dest -- dest ) \ Compilation
       ( flag -- )    \ Execution
   0 CS-PICK POSTPONE UNTIL
; IMMEDIATE

: XX ( -- ) \ Example use of ?REPEAT
   BEGIN
     ...
   flag ?REPEAT ( Go back to BEGIN if flag is false )
     ...
   flag ?REPEAT ( Go back to BEGIN if flag is false )
     ...
   flag UNTIL ( Go back to BEGIN if flag is false )
;

Testing:
: ?repeat
   0 CS-PICK POSTPONE UNTIL
; IMMEDIATE

VARIABLE pt4

: <= > 0= ;

T{ : pt5  ( n1 -- ) 
      pt4 ! 
      BEGIN 
        -1 pt4 +! 
        pt4 @ 4 <= ?repeat    \ Back to BEGIN if false 
        111 
        pt4 @ 3 <= ?repeat 
        222 
        pt4 @ 2 <= ?repeat 
        333 
        pt4 @ 1 = 
      UNTIL 
    ; -> }T

T{ 6 pt5 -> 111 111 222 111 222 333 111 222 333 }T