Because we have redefined the left parenthesis, from this point on,
inline comments must be done with a double left parenthesis.
: (( ( -- ) POSTPONE ( ; IMMEDIATE
: ( (( -- ) ['] DUMMY >BODY >P ; IMMEDIATE
PREVIOUS FORTH
\ ----- End of code -----
Defining KISS-commands
KISS + KISS - KISS * KISS /
Indeed, that's all there is to it to make KISS-commands out of existing Forth words!
From this point on,
+ - * and
/ act (almost) like they do in,
e.g., BASIC. Or to put a finer point on it:
-
A KISS-command uses the immediately following word as its argument:
infix-notation, ex. 1.
-
When a left parenthesis is found, all words up to the right parenthesis are arguments: prefix-notation, ex. 2.
Take care:
-
Parentheses are Forth words and must be separated by at least one space
from the preceding or following text.
-
Precendence rules are not implemented (check out ex. 3, 4 and 5).
1) BASE @ + 1 . \ 11
2) 1 + ( BASE @ ) . \ 11
3) 3 + 4 * 5 . \ 35
4) ( 3 + 4 ) * 5 . \ 35
5) 3 + ( 4 * 5 ) . \ 23
KISS-commands work inside definitions.
: DOZEN (( x -- x*12 ) * 12 ;