Move OUT-OF-RANGE from lib/array.fs to lib/core.fs

This commit is contained in:
Koichi Nakamura 2021-12-08 07:42:38 +09:00
parent 8a3d114ae5
commit 0710e59677
2 changed files with 3 additions and 3 deletions

View file

@ -5,7 +5,6 @@
private{
( === Allocation strategy === )
defined? array-alloc-strategy [unless]
\ Compute new capacity
@ -21,8 +20,6 @@ struct
int% field array>capa
end-struct array%
s" Index out of range" exception constant OUT-OF-RANGE export
\ Allocate array with capacity
: allocate-array ( n capa -- arr )
array% %allocate throw

View file

@ -16,6 +16,9 @@ s" Invalid argument" exception constant INVALID-ARGUMENT
unless INVALID-ARGUMENT throw then
;
( === Builtin Exceptions === )
s" Index out of range" exception constant OUT-OF-RANGE export
defined? roll [unless]
: roll ( w[n-1] ... w0 n -- w0 w[n-2] ... w0 w[n-1] )
dup 0<= if drop else swap >r 1- recurse r> swap then