version 1.30, 1996/01/25 16:45:50
|
version 1.31, 1996/02/09 17:34:09
|
Line 1141 system that only supplies @code{THEN} is
|
Line 1141 system that only supplies @code{THEN} is
|
Forth's @code{THEN} has the meaning 2b, whereas @code{THEN} in Pascal |
Forth's @code{THEN} has the meaning 2b, whereas @code{THEN} in Pascal |
and many other programming languages has the meaning 3d.] |
and many other programming languages has the meaning 3d.] |
|
|
We also provide the words @code{?dup-if} and @code{?dup-0=-if}, so you |
Gforth also provides the words @code{?dup-if} and @code{?dup-0=-if}, so |
can avoid using @code{?dup}. |
you can avoid using @code{?dup}. Using these alternatives is also more |
|
efficient than using @code{?dup}. Definitions in plain standard Forth |
|
for @code{ENDIF}, @code{?DUP-IF} and @code{?DUP-0=-IF} are provided in |
|
@file{compat/control.fs}. |
|
|
@example |
@example |
@var{n} |
@var{n} |
Line 1325 doc-else
|
Line 1328 doc-else
|
doc-while |
doc-while |
doc-repeat |
doc-repeat |
|
|
|
Gforth adds some more control-structure words: |
|
|
|
doc-endif |
|
doc-?dup-if |
|
doc-?dup-0=-if |
|
|
Counted loop words constitute a separate group of words: |
Counted loop words constitute a separate group of words: |
|
|
doc-?do |
doc-?do |
Line 1724 E.g., a definition using @code{TO} might
|
Line 1733 E.g., a definition using @code{TO} might
|
: strcmp @{ addr1 u1 addr2 u2 -- n @} |
: strcmp @{ addr1 u1 addr2 u2 -- n @} |
u1 u2 min 0 |
u1 u2 min 0 |
?do |
?do |
addr1 c@ addr2 c@ - ?dup |
addr1 c@ addr2 c@ - |
if |
?dup-if |
unloop exit |
unloop exit |
then |
then |
addr1 char+ TO addr1 |
addr1 char+ TO addr1 |
Line 1747 are initialized with the right value for
|
Line 1756 are initialized with the right value for
|
addr1 addr2 |
addr1 addr2 |
u1 u2 min 0 |
u1 u2 min 0 |
?do @{ s1 s2 @} |
?do @{ s1 s2 @} |
s1 c@ s2 c@ - ?dup |
s1 c@ s2 c@ - |
if |
?dup-if |
unloop exit |
unloop exit |
then |
then |
s1 char+ s2 char+ |
s1 char+ s2 char+ |