Error loading plugin include
ParseError: syntax error, unexpected 'include' (T_INCLUDE), expecting identifier (T_STRING) or '{'
More info is available in the error log.
ParseError: syntax error, unexpected 'include' (T_INCLUDE), expecting identifier (T_STRING) or '{'
More info is available in the error log.
words:checked-array
require ",
VARIABLE range-checking TRUE range-checking !
: Unchecked-Array ( n -- )
CREATE CELLS ALLOT
DOES> ( n -- addr )
SWAP CELLS + ;
: Checked-Array ( n -- )
HERE >IN @ BL WORD COUNT ", >IN ! ( n c-addr )
CREATE OVER , COUNT , , CELLS ALLOT
DOES> ( n -- addr )
range-checking @ IF
>R DUP R@ @ U< 0=
IF ." Index out of range in Array '" R@ CELL+ 2@ TYPE
." '! Actual Index: " U.
." Maximal Index: " R@ @ 1- U. ABORT
THEN
R>
THEN
3 CELLS + SWAP CELLS + ;
: Array ( n -- ) range-checking @ IF Checked-Array ELSE Unchecked-Array THEN ;
Tags: ANS-Forth data-structures safety bounds checking
words/checked-array.txt · Zuletzt geändert: von 127.0.0.1