home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
pd6.lzh
/
TST
/
macros.tst
< prev
next >
Wrap
Text File
|
1989-12-21
|
627b
|
43 lines
.( Loading Macro test...) cr
#include macros.f83
macros
.( 1: Define "nip" and mark it as a macro definition) cr
: nip ( a b -- b) swap drop ; macro
.macro nip cr
1 2 nip . cr
: x ( a b -- b) nip ;
1 2 x . cr
.( 2: Define "mip" as a double "nip" macro) cr
: mip ( a b c -- c) nip nip ; macro
.macro mip cr
1 2 3 mip . cr
.( 3: Conditional code may also be used as a macro) cr
: 0<> ( x -- flag) 0= if false else true then ; macro
.macro 0<> cr
1 0<> . 0 0<> . cr
.( 4: Macros in macros work the way they should) cr
: ?1- ( x -- [x-1] or [0]) dup 0<> if 1- then ; macro
.macro ?1- cr
10 ?1- . cr
forth only