- 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.1.2380 UNLOOP CORE
Interpretation:
Execution:
Discard the loop-control parameters for the current nesting level. An UNLOOP is required for each nesting level before the definition may be EXITed. An ambiguous condition exists if the loop-control parameters are unavailable.
See:
Rationale:
UNLOOP allows the use of EXIT within the context
of DO ... LOOP and related do-loop constructs.
UNLOOP as a function has been called UNDO
.
UNLOOP is more indicative of the action: nothing gets
undone — we simply stop doing it.
Testing:
0 SWAP 0 DO
I 1+ 0 DO
I J + 3 = IF I UNLOOP I UNLOOP EXIT THEN 1+
LOOP
LOOP ; -> }T
T{ 1 GD6 -> 1 }T
T{ 2 GD6 -> 3 }T
T{ 3 GD6 -> 4 1 2 }T
ContributeContributions
AtH [18] Another use of UNLOOPSuggested Testcase2016-05-16 21:55:15
Old standard concentrates on UNLOOP EXIT
I suggest to legalize in the new standard UNLOOP LEAVE for breaking the outer loop.
ruv [339] Is it possible to eliminate the need for `UNLOOP`?Request for clarification2024-05-13 08:33:18
The need for the UNLOOP
word can be eliminated in two different ways:
In compilation time. When the compilation semantics for
EXIT
are performed, the number of containingDO ... LOOP
structures is known, so the corresponding number of an internal word(UNLOOP)
can be compiled automatically beforeEXIT
.In run-time. When the
DO
run-time semantics are performed, an internal word(UNLOOP-EXIT)
entry point can be placed on the return stack as a part of loop-sys; then, ifEXIT
run-time semantics are performed inside the loop,(UNLOOP-EXIT)
takes control, removes other loop-sys params and performs the run-time semantics ofEXIT
; ifEIXT
run-time are not performed inside the loop,(UNLOOP-EXIT)
is removed byLOOP
run-time semantics as a part of loop-sys.
In any case, these approaches should be used by Forth systems to remove the local variables frame before exiting.
If the UNLOOP
word is not needed, the stack diagram for the EXIT
run-time semantics would be:
Run-time EXIT
: ( R: i*loop-sys nest-sys -- )
Do you think it is theoretically possible in the future? For backward compatibility, UNLOOP
can be implemented as a synonym of NOP
.
Rationale
- slightly simpler and less error-prone code (you cannot miss
UNLOOP
if you don't need it at all); - more consistent language (why we don't need an analog of
UNLOOP
to manually remove a local variables frame?); - don't do manually what the system can do automatically.