next up previous contents index
Next: Macros.4th Up: Dreams Previous: Ans.4th   Contents   Index



Edo.4th


(

                   Extended Data Objects for Forth.

                      Written by George Hawkins
                 Moderator of the "Fifth" Conference
                    On the East Coast Forth Board

           Modified by R. J. Brown, Elijah Laboratories Inc.

   Modified to be compatible with ANS X3/J14-TC BASIS6, and also to permit
more flexibility in structure declarations, especially with regard to
vectors.

)

: DEF ( type -- ) \ C			   \ Define a scalar type.
      \ <type> \ 
      ( -- type ) \ R
      CONSTANT ;


: S{ ( -- offset )			   \ Initiate a structure definition.
     0 ;


: :: ( old-offset type -- new-offset ) \ C \ Define a structure component.
     \ <component> \
     ( -- new-offset ) \ R
     CREATE OVER , + 
     DOES> @ + ;


: }S ( offset -- type )  		   \ End a structure definition.
     ; 


: [*] ( object-definition -- ) \ C	   \ Define a vector operator.
      \ <vector-operator> \
      ( index base-addr -- element-addr ) \ R
      DUP CREATE ,             
      DOES> @ ROT * + ;        


: DEF[] ( element-type #elements -- ) \ C  \ Define a vector.
        \ <vector-type> \
        ( -- vector-type ) \ R
        * CONSTANT ;



Robert J. Brown
1999-09-26