Arrays with bounds checking#

\ Arrays with bounds checking

| : (ARRAYERROR 
    ABORT" Array out of bounds!" ; 

: ARRAY ( size -- )
  CREATE DUP , 2* ALLOT
  DOES> ( i -- addr )
  OVER        0< (ARRAYERROR
  2DUP @ 1- - 0> (ARRAYERROR
  SWAP 1+ 2* + ;

: CARRAY ( size -- )
  CREATE DUP , ALLOT
  DOES> ( i -- addr )
  OVER        0< (ARRAYERROR
  2DUP @ 1- - 0> (ARRAYERROR
  + 1+ ;

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-1) was last changed on 24-Apr-2010 22:24 by Carsten Strotmann