]> gitweb.factorcode.org Git - factor.git/commitdiff
core: rename ensure-non-negative to assert-non-negative
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 21 Feb 2023 03:13:08 +0000 (21:13 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 26 Feb 2023 23:11:04 +0000 (17:11 -0600)
basis/fixups/fixups.factor
basis/math/bits/bits.factor
basis/math/bitwise/bitwise.factor
core/math/math.factor
core/sequences/sequences.factor
extra/base32-crockford/base32-crockford.factor
extra/math/extras/extras.factor

index 72a3d6b4895dc7b0f7ca3935ddabd142f5dfe9b6..75d2d309bff78744d6c5634c7aeb5f6d0145124e 100644 (file)
@@ -64,6 +64,7 @@ CONSTANT: word-renames {
     { "more?" { "deref?" "0.99" } }
     { "plox" { "?transmute" "0.99" } }
     { "?if" { "?if-old" "0.99" } }
+    { "ensure-non-negative" { "assert-non-negative" "0.99" } }
 }
 
 : compute-assoc-fixups ( continuation name assoc -- seq )
index 998ff0349cd009fd05d10313bb9ac5695a82e8aa..b8a597e48ce4620e0b433c0a5c8733bd89e121c0 100644 (file)
@@ -7,7 +7,7 @@ TUPLE: bits { number read-only } { length read-only } ;
 C: <bits> bits
 
 : make-bits ( number -- bits )
-    ensure-non-negative
+    assert-non-negative
     [ T{ bits f 0 1 } ] [ dup abs log2 1 + <bits> ] if-zero ; inline
 
 M: bits length length>> ; inline
index 30408bcf22a37d521e423e6aeafbcb5229cdaddd..f74bcc1620f0c088e1cc635f0dfe17cdcf2c5184 100644 (file)
@@ -134,7 +134,7 @@ PRIVATE>
 GENERIC: bit-count ( obj -- n )
 
 M: integer bit-count
-    ensure-non-negative (bit-count) ; inline
+    assert-non-negative (bit-count) ; inline
 
 M: byte-array bit-count
     byte-array-bit-count ;
index 619ea67813b4ed18ba20a8832e6bdc3aa033a740..8b28ad5b87b32ad7b63c834c64fd5587fd3c4bc7 100644 (file)
@@ -131,6 +131,11 @@ GENERIC: (log2) ( x -- n ) foldable
 
 PRIVATE>
 
+ERROR: non-negative-integer-expected n ;
+
+: assert-non-negative ( n -- n )
+    dup 0 < [ non-negative-integer-expected ] when ; inline
+
 : recursive-hashcode ( n obj quot -- code )
     pick 0 <= [ 3drop 0 ] [ [ 1 - ] 2dip call ] if ; inline
 
index fc9e31376374eea3902bfc61fb8795a314dc3e4d..12804ccb5c42c03e9f8ce40289a25f61242454dc 100644 (file)
@@ -111,13 +111,8 @@ INSTANCE: f immutable-sequence
 ! Integer sequences
 TUPLE: iota { n integer read-only } ;
 
-ERROR: non-negative-integer-expected n ;
-
-: ensure-non-negative ( n -- n )
-    dup 0 < [ non-negative-integer-expected ] when ; inline
-
 : <iota> ( n -- iota )
-    ensure-non-negative iota boa ; inline
+    assert-non-negative iota boa ; inline
 
 M: iota length n>> ; inline
 M: iota nth-unsafe drop ; inline
index 110f70229d3cc9b2e343818f4f2ff2734e1e8ae8..f4d1310bd49e41c9f75e49f2f70e42f276502247 100644 (file)
@@ -31,7 +31,7 @@ PRIVATE>
     normalize-base32 parse-base32 ;
 
 : >base32-crockford ( n -- base32 )
-    ensure-non-negative
+    assert-non-negative
     [ dup 0 > ] [ 32 /mod ALPHABET nth ] "" produce-as nip
     [ "0" ] when-empty reverse! ;
 
index 4d65a2d386049f232cdc8e5b2d0677d7440db410..1e4d3b922c7085168de221a7e47a8a8b1fa56e0e 100644 (file)
@@ -355,7 +355,7 @@ PRIVATE>
 
 :: integer-sqrt ( m -- n )
     m [ 0 ] [
-        ensure-non-negative
+        assert-non-negative
         bit-length 1 - 2 /i :> c
         1 :> a!
         0 :> d!