add DO LOOP +LOOP to example/compat.forth

FossilOrigin-Name: 1c2c94fff681153c259cddf2ab9d1a60e042d7270ea0190f5965b3d36429d5ce
This commit is contained in:
crc 2019-05-13 17:29:20 +00:00
parent 8992c742fc
commit 1e1e5e469d
2 changed files with 15 additions and 6 deletions

View file

@ -53,6 +53,9 @@ with tradition as well as the minimal requirements of ANS.
:AGAIN |again ; immediate
:FOR |[ ; immediate
:NEXT |] |times<with-index> ; immediate
:DO |[ |[ |[ ; immediate
:LOOP |] |dip |] |dip |n:inc |dup-pair |gt? |] |while |drop-pair ; immediate
:+LOOP |] |dip |] |dip |swap |push |+ |pop |swap |dup-pair |gt? |] |while |drop-pair ; immediate
~~~
## I/O
@ -172,7 +175,8 @@ The following words are not supported due to design choices in RETRO.
-------- -------- -------- -------- -------- --------
# #> #S ' ( ."
['] : >IN [CHAR] ABORT" CONSTANT
CREATE POSTPONE S" SOURCE VARIABLE WORD
CREATE EXIT POSTPONE S" SOURCE VARIABLE
WORD
-------- -------- -------- -------- -------- --------
The following are not supported due to limitations of the VM.

View file

@ -1,6 +1,10 @@
The standard RETRO language provides `bi` and `tri` combinators to apply quotes to two or three values in various combinations. Sometimes it may be necessary to do this with four values.
The standard RETRO language provides `bi` and `tri` combinators
to apply quotes to two or three values in various combinations.
Sometimes it may be necessary to do this with four values.
Note that this is *ugly* code. It's functional, but if you can refactor to avoid needing it, it'll likely be better in the long run.
Note that this is *ugly* code. It's functional, but if you can
refactor to avoid needing it, it'll likely be better in the long
run.
`quad` applies four quotes to a value. These are equivilent:
@ -19,7 +23,8 @@ Note that this is *ugly* code. It's functional, but if you can refactor to avoid
pop pop call ;
~~~
`quad*` takes eight values (!) and applies each quote to a specific value. E.g., these are equivilent:
`quad*` takes eight values (!) and applies each quote to a
specific value. E.g., these are equivilent:
#10 [ #1 + ] call
#11 [ #1 - ] call
@ -36,7 +41,8 @@ Note that this is *ugly* code. It's functional, but if you can refactor to avoid
pop pop call ;
~~~
`quad@` takes four values and a quote, and applies the quote to each value in order. These are equivilent:
`quad@` takes four values and a quote, and applies the quote to
each value in order. These are equivilent:
#10 [ #1 + ] call
#11 [ #1 + ] call
@ -49,4 +55,3 @@ Note that this is *ugly* code. It's functional, but if you can refactor to avoid
:quad@ (abcdq-)
'abcde 'abcdeeee reorder quad* ;
~~~