home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / FPC225_2.ZIP / MISC.ZIP / EDO.SEQ < prev    next >
Encoding:
Text File  |  1988-01-28  |  1.3 KB  |  49 lines

  1. \    Extended Data Objects for Forth.  GTH 07/28/87
  2.  
  3. .comment:
  4.     See file EDO.TXT for documentation, file EDODMO.Seq for
  5. a test/demonstration/examples of code.
  6. comment;
  7. 20 tillkey
  8.  
  9. \ Machine characteristics & scalar definition       GTH 07/28/87
  10.  
  11. 1 CONSTANT 1BYTE   : BYTE* ;
  12.  
  13. \ Modify line below to number of bytes per machine word:
  14. 2 CONSTANT 1WORD ( -- n )   \ the machine word/cell size
  15.  
  16. : WORD+ ( n -- n+WORD )     \ increments by word size
  17.   1WORD + ;
  18.  
  19. : WORD* ( n -- n*WORD )     \ multiplies by word size
  20.   1WORD * ;
  21.  
  22. : DEF ( size -- )           \ defines a Forth scalar
  23.   CONSTANT ;
  24.  
  25. \ The structure data object                         GTH 07/28/87
  26.  
  27. \ Initiates a structure definition.
  28. : S{ ( -- 0 )
  29.   0 ;
  30.  
  31. \ Defines a structure component.
  32. : :: ( offset object-definition -- offset )
  33.   CREATE OVER , + DOES> @ + ;
  34.  
  35. \ Ends a structure definition & defines a structure object.
  36. : }S ( size -- )  \ definition name follows in input stream
  37.   CONSTANT ;
  38.  
  39. \ The vector data object                            GTH 07/28/87
  40.  
  41. \ Defines a vector and a vector operator.
  42. : [] ( object-definition #objects -- )
  43. \ Input stream must contain: definition name & operator name.
  44. \ Higher dimensionality objects are vectors of vectors!
  45.   OVER * CONSTANT  \ define the vector
  46.   CREATE ,         \ define the vector operator
  47.   DOES> @ * + ;
  48.  
  49.