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 >
Text File  |  1989-12-21  |  627b  |  43 lines

  1. .( Loading Macro test...) cr
  2.  
  3. #include macros.f83
  4.  
  5. macros
  6.  
  7. .( 1: Define "nip" and mark it as a macro definition) cr
  8.  
  9. : nip ( a b -- b) swap drop ; macro
  10.  
  11. .macro nip cr
  12. 1 2 nip . cr
  13.  
  14. : x ( a b -- b)  nip ;
  15.  
  16. 1 2 x . cr
  17.  
  18.  
  19. .( 2: Define "mip" as a double "nip" macro) cr
  20.  
  21. : mip ( a b c -- c) nip nip ; macro
  22.  
  23. .macro mip cr
  24. 1 2 3 mip . cr
  25.  
  26.  
  27. .( 3: Conditional code may also be used as a macro) cr
  28.  
  29. : 0<> ( x -- flag) 0= if false else true then ; macro
  30.  
  31. .macro 0<> cr
  32. 1 0<> . 0 0<> . cr
  33.  
  34.  
  35. .( 4: Macros in macros work the way they should) cr
  36.  
  37. : ?1- ( x -- [x-1] or [0]) dup 0<> if 1- then ; macro
  38.  
  39. .macro ?1- cr
  40. 10 ?1- . cr
  41.  
  42. forth only
  43.